Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
In my application I used firefox to download a file from a server. But I dont know how to change the default download location through my C# code. Is it impossible??
Can someone please help me?? urgent

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 5-Jun-12 0:44am    
I wonder why?
--SA
Dhanushka Madushan lk 5-Jun-12 0:50am    
I need to store these files in a specific folder. If I do it manually all the files will go that folder. Thats why I have to change the path in my code and reset after I done..
Can u please help me
Sergey Alexandrovich Kryukov 5-Jun-12 0:53am    
Yes. Please see my answer. This is pretty easy to do.
--SA

1 solution

I see no sense in using Firefox. This is the same as scratching your right ear with you left foot.

To download a file, you just need to use System.Net.HttpWebRequest. Please see:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^].

In case you may need to authenticate with some credentials, here is the download code sample:
http://stackoverflow.com/questions/4699938/how-to-download-the-file-using-httpwebrequest-and-httpwebresponse-classcookies[^].

Another option is using the class System.Net.WebClient and one of its download methods. Please see:
http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx[^].

The WebClient methods are simplified, but without advanced functionality possible with HttpWebRequest.

—SA
 
Share this answer
 
v3
Comments
Dhanushka Madushan lk 5-Jun-12 0:51am    
Thanks
Sergey Alexandrovich Kryukov 5-Jun-12 0:52am    
Sure. I just added a link with code sample.
If you agree that it makes sense, please accept the answer formally (green button) -- thanks.
--SA
Shahin Khorshidnia 5-Jun-12 2:00am    
Good links. +5
Sergey Alexandrovich Kryukov 5-Jun-12 11:20am    
Thank you, Shahin.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900