I need to create a program that can read a file a user has selected, i'm trying to use this with the HtmlInputFile in Visual Studio.
The file then needs to be read and encoded, i've created a class that deals with the encoding and adds +13 onto each letter to encode it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
namespace Coursework_Exercise2Web
{
public class encode
{
private string encodedMessage;
private char[] originalMessage = new char[100];
public string encodeMess(string m)
{
originalMessage = m.ToCharArray();
for (int i = 0; i < originalMessage.Length; i++)
{
originalMessage[i] = (Char)(originalMessage[i] + 13);
encodedMessage += originalMessage[i];
}
return encodedMessage;
}
public string decodeMess(string m)
{
originalMessage = m.ToCharArray();
for (int i = 0; i < originalMessage.Length; i++)
{
originalMessage[i] = (Char)(originalMessage[i] - 13);
encodedMessage += originalMessage[i];
}
return encodedMessage;
}
}
}
I now want to know how to create in ASP.net a file upload so that user can select browse for a file and then the system will encode the text from the file they have uploaded. I've used the HTML input (file) however I need to try and program this to encode the users file.
Thank you.