As Im new to C# and I am stuck with a very basic problem.
I am reading one text file, which contains some data(for example "hello") I am reading this data like the code mentioned below.
System.IO.Stream myStream;
Int32 fileLen;
StringBuilder displayString = new StringBuilder();
// Get the length of the file.
fileLen = FileUploadId.PostedFile.ContentLength;
// Display the length of the file in a label.
string strLengthOfFileInByte = "The length of the file is " +
fileLen.ToString() + " bytes.";
// Create a byte array to hold the contents of the file.
Byte[] Input = new Byte[fileLen];
// Initialize the stream to read the uploaded file.
myStream = FileUploadId.FileContent;
// Read the file into the byte array.
//myStream.Read(Input, 0, fileLen);
myStream.Read(Input, 0, fileLen);
// Copy the byte array to a string.
for (int loop1 = 0; loop1 < fileLen; loop1++)
{
displayString.Append(Input[loop1].ToString());
}
// Display the contents of the file in a
string strFinalFileContent = displayString.ToString();
return strFinalFileContent;
I want "hello" should be the value of 'strFinalFileContent'. I am getting "104 101 108 108 111" means decimal values of ASCII characters. Please help me how to get "h e l l o" as output. It might me small question, But I m beginner So please help me.