1 Replies - 245 Views - Last Post: 05 October 2012 - 01:03 PM Rate Topic: -----

#1 sameer1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 05-October 12

convert uploaded file into stream...is this right way ?

Posted 05 October 2012 - 12:44 PM

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 final output

Is This A Good Question/Topic? 0
  • +

Replies To: convert uploaded file into stream...is this right way ?

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3467
  • View blog
  • Posts: 10,687
  • Joined: 05-May 12

Re: convert uploaded file into stream...is this right way ?

Posted 05 October 2012 - 01:03 PM

Closing this thread in favor for the other thread that was moved into the C# forum.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1