Read PostedFile Directly into a String Variable
Posted on 2004-11-01
I'm uploading a file through a form using a File server control.
The file uploads fine into memory, and I can save the file to disk using a line of code such as "MyFile.PostedFile.SaveAs...."
What I really want to do is that this entire file, and get it into a String variable (without having to save it to disk at all). The contents of the file are just plain text with line breaks (no null characters or anything). I'm pretty sure I'd use the MyFile.PostedFile.InputStream.Read method, but it looks like this method returns an integer, or perhaps an array of bytes.
So, I guess my question is.. How do I get the entire contents of a file uploaded through a File server control into a String variable, assuming the file contains no special characters other than line breaks. I do NOT want to save the file to a disk first and then re-read it through an StreamReader object.
Thanks in advance,