Hi,
I want to read a file from a http request (say, http://www.foo.com/test.exe)
to my local hard drive. How can I do that? I need specific code examples
here, not just "use HttpRequest and get a Stream and write that stream to
disc with BinaryWriter". This is what I have gotten to so far, it probably
looks stupid if you know how to do it, but I can't find much help on the web
Uri downloadLoc = new Uri("http://www.foo.com/files/Test.exe");
HttpWebRequest req = (HttpWebRequest) WebRequest.Create(downloadLoc);
long length = req.ContentLength;
WebResponse rsp = req.GetResponse();
Stream inStream = rsp.GetResponseStream();
File.Delete(Application.StartupPath + "Test.tmp");
FileStream fs = File.Create(Application.StartupPath + "Transport.tmp");
while(inStream.Position < inStream.Length)
fs.WriteByte((byte)inStream.ReadByte());