http Text File 
 For a customer I should download from a website ( http://.../mytext.php ) a file and save the text on a server share. And as simple as that. NET 2.0. 
 
 / / Get stream from any Web server over HTTP response object 
 WebRequest request = (WebRequest) WebRequest.Create (new Uri ("http://.../mytext.php")); 
 WebResponse response = request.GetResponse (); 
 / / create reader to read the stream and save it in a string 
 StreamReader reader = new StreamReader (response.GetResponseStream ()); 
 / / write string to a file 
 File.WriteAllText (@ "c: / test.txt "reader.ReadToEnd ()); 
 / / close objects 
 reader.Close (); 
 response.Close ();  
0 comments:
Post a Comment