System.IO.Stream myStream;
Int32 fileLen;
Stream myStream1 = new MemoryStream();
// Get the length of the file.
fileLen = FileUpload1.PostedFile.ContentLength;
// Create a byte array to hold the contents of the file.
Byte[] Input = new Byte[fileLen];
UnicodeEncoding uniEncoding = new UnicodeEncoding();
// Initialize the stream to read the uploaded file.
myStream = FileUpload1.FileContent;
// Read the file into the byte array.
myStream.Read(Input, 0, fileLen);
string value = ASCIIEncoding.ASCII.GetString(Input);
using (StreamWriter sw = new StreamWriter(myStream1, uniEncoding))
{
sw.Write(value);
}
//myStream will be the output
System.IO.Stream myStream;
Int32 fileLen;
Stream myStream1 = new MemoryStream();
// Get the length of the file.
fileLen = FileUpload1.PostedFile.ContentLength;
// Create a byte array to hold the contents of the file.
Byte[] Input = new Byte[fileLen];
UnicodeEncoding uniEncoding = new UnicodeEncoding();
// Initialize the stream to read the uploaded file.
myStream = FileUpload1.FileContent;
// Read the file into the byte array.
myStream.Read(Input, 0, fileLen);
string value = ASCIIEncoding.ASCII.GetString(Input);
using (StreamWriter sw = new StreamWriter(myStream1, uniEncoding))
{
sw.Write(value);
}
//myStream1 will be output
This post has been edited by AdamSpeight2008: 05 October 2012 - 12:30 PM
Reason for edit:: Added in code tags

New Topic/Question
Reply



MultiQuote





|