Click here to Skip to main content
15,921,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m using web browser control where to download file where URL generate file dynamically. url contains file name and type(.csv\txt etc) after requesting that URL some website create file dynamically and then open/save dialog comes. for example some link generate pdf file on the fly.How to handle such type of URL?
I m not able to download programaticaly please help.

Shrikant
Posted

Here is an example
C#
private void button1_Click(object sender, EventArgs e)
 {
     WebRequest objReq = WebRequest.Create("http://www.martinfowler.com/ieeeSoftware/patterns.pdf");
     WebResponse objResp = objReq.GetResponse();
     Stream objStream = objResp.GetResponseStream();
     StreamReader reader = new StreamReader(objStream,Encoding.ASCII);
     FileStream fStream = new FileStream("Test.pdf", FileMode.Create);
     StreamWriter writer=new StreamWriter(fStream);
     writer.Write(reader.ReadToEnd());
     objStream.Close();
     reader.Close();
     writer.Close();
     fStream.Close();

 }
 
Share this answer
 
Comments
shrikant003 14-Feb-11 4:47am    
in my case url does not contain file path directly insted it is creating file dynamicaly from the URL
Albin Abel 14-Feb-11 4:55am    
Tell me an example of such url. Thanks
shrikant003 14-Feb-11 4:59am    
https://products.abcdef.com/warehouse/export.jsp?date=11Feb11&type=credvolindex&report=VOLATILITY_INDICES&version=4&format=csv&ticker=&fromdate=&todate=&time=1297668112229&v5history=&idtype=&idvalue=&doNotGzip=true&
Albin Abel 14-Feb-11 12:09pm    
The URL you give not working for me. However you may explain what will be the result once this url loaded in the browser
shrikant003 16-Feb-11 8:37am    
Thnks Alot...... I got my answer at http://brokethebuild.blogspot.com/

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