FileUpload to FileStream?

Might be better to pipe the input stream directly to the output stream.

Might be better to pipe the input stream directly to the output stream: inputStream. CopyTo(outputStream); This way, you are not caching the entire file in memory before re-transmission. For example, here is how you would write it to a FileStream: FileUpload fu; // Get the FileUpload object.

Using (FileStream fs = File. OpenWrite("file. Dat")) { fu.PostedFile.InputStream.

CopyTo(fs); fs.Flush(); } If you wanted to write it directly to another web request, you could do the following: FileUpload fu; // Get the FileUpload object for the current connection here. HttpWebRequest hr; // Set up your outgoing connection here. Using (Stream s = hr.

GetRequestStream()) { fu.PostedFile.InputStream. CopyTo(s); s.Flush(); } That will be more efficient, as you will be directly streaming the input file to the destination host, without first caching in memory or on disk.

You can't convert a FileUpload into a FileStream. You can, however, get a MemoryStream from that FileUpload's PostedFile property. You can then use that MemoryStream to fill your HttpWebRequest.

Since FileUpload.PostedFile. InputStream gives me Stream, I used the following code to convert it to byte array public static byte ReadFully(Stream input) { byte buffer = new byteinput. Length; //byte buffer = new byte16 * 1024; using (MemoryStream ms = new MemoryStream()) { int read; while ((read = input.

Read(buffer, 0, buffer. Length)) > 0) { ms. Write(buffer, 0, read); } return ms.ToArray(); } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions