Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
hi,
I need to download the files[XML/PDF] using webbrowser control. In hyperlink they have written javascript to make POST method and they are submitting the form. so i couldnt take absolute file path to download teh file using "Webclient". Every time its asking the open/save dialog box. i want to avoid the same.

Kindly help me out

Thanks in advance
Bell
Posted
Comments
Albin Abel 9-Mar-11 6:28am    
"In hyperlink they have written javascript to make POST method" looks like some ajax call. Post the hyperlink mark up and the associated javascript. So it is better for you to get answers

1 solution

Using System.Net.Webclient, you can easily download the file on the Web url, make sure that the file path is relative to the web url e.g. If the example.jpg is hosted in the root of www.example.com then use like,

WebClient wc = new WebClient();
wc.DownloadFile("http://www.example.com/example.jpg", @"C:\example.jpg");


You need to pass the local physical path to avoid open/save file dialog.

Find more info here
 
Share this answer
 
Comments
pnileshin 30-Jan-13 7:51am    
how to download the file that is generated dynamically using javascript (code is written in .js file) i tries httprequest, webclient, my.computer.network.downloadfile and all possible ways however when it reaches to read content shows popup for download file
Naveed727 9-Mar-13 2:29am    
In case you are going to download a file that need to be in Web Browser session else you can't download the file than what should I do?

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