Is it possible to use some .NET library to download a file from the internet automatically to a specified directory Let's say I have an excel chart on my website, and I want to download it to C://
Also, I want to be able to do the same with a web page, i.e., I want to go to www.mywebpage.com/index.html and download index.html to a certain folder by using .NET.
Will this take a lot of complicated code Can I just use a .NET library, or must I use Win32 API or something like that

Using Internet From C#
Evan Mulawski
Also, about File Downloading and Uploading. In WebRequestMethods there is http, ftp, and file, how do I access file and ftp
What is the difference between that (webrequest) and Web Client
Also, how can I get the progress of a download or upload
AlexBB
Hi xRuntime,
you can use Image.FromStream to create an Image instance from the Stream you get as Response of your WebRequest call. Your picture box has an Image property which you assign the Image instance to.
--
SvenC
lord_8
you could use a memorystream to save the image, then tell the PictureBox to load it from the memorystream.
Johanvh
you have a couple of choices
1) use the WebBrowser control in .NET 2.0 to navigate to a website and save the document
2) use a WebRequest and WebResponse classes to read the Stream of data returned overall and save it to a file
which one are you after :-)
Preeteesh
2) yes, thats what im after, but I somewhat accomplished it
following these directions http://www.csharpfriends.com/Articles/getArticle.aspx articleID=115
I can upload and download file
however, what would be best is that instead of saving the file to the computer, accessing the file from the internet and using it dynamically in the program, that is what I want to do...
for example, I want to access a picture from the web and display it in a picture box
thanks
SterlingH
pasha2k
I've figured out how to use the event progress changed, but I cant get the actual percent of progress or file size done, how would I do that
Esqueleto
so are you using a webbrowser control now to do this or something else
the actual percentage you may have to calculate yourself depending on how many bytes were downloading and how many bytes remaining. Can you explain how you are getting and using the event progress changed
John Mathews
Jonas.S
I get so many errors!!
What is wrong
schmod54
ok well I was thinking you were talking about just a webpage and not an image but if its an image directly then yes that makes things a whole load easier
using trimstart and all the string stuff is very messy and can have unpredicated results somethings therefore doing Regex does things properly for you (assuming you entered the correct "formula")
So now, since you have the image path, simply use the WebResponse/Request classes to read the image directly into a Stream , then tell the picturebox to load the image from the stream.
WebRequest theRequest = WebRequest.Create("ImageUrl");
WebResponse theResponse = theRequest.GetResponse();
using (StreamReader theReader = new StreamReader(theResponse.GetResponseStream());
{
this.thePictureBox.Image = Image.FromStream(theReader.BaseStream);
}
acf
no worries. Yes the forum is very dodgy again today so you have to bare with us. Please do come back and mark the answers once the forums are back up.
to get the progress bar indication, there have been a few threads here - do a forum search and you will have some hits. Take a look at the class, there should also be some examples:
If you had a WebBrowser control, things would be alot easier as there is a FileDownload event from which you can calculate easily the progress and so on but since this is not what you may be doing, you can still achieve what you are after using the resource given as well as the examples in these forums.
2) Video streaming, im not entirely sure. WME - Windows Media Encoder - would be the best bet for streaming audio/video content from your computer. In C#, it may well be possible using the Stream classes (FileStream/MemoryStream/StreamReader/Writer) and some TCP/IP Communication (Sockets, TCPClient/TCPListener/NetworkStream classes)
if you are using a WMP Control then simply just give it the url to the media file and it will do the rest itself.
Hope this works for you!
Palvinder Singh
All the event handlers etc. are in there, but I dunno how to even get the bytes and all that..if i did, it would be somewhat easy to get the percentage and update a progress bar..
Octopus384