Use WebClient to download information into a file : Web Client : Network C# Source Code


Custom Search

C# Source Code » Network » Web Client »

 

Use WebClient to download information into a file









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/


// Use WebClient to download information into a file. 
 
using System; 
using System.Net; 
using System.IO; 
 
public class WebClientDemo {  
  public static void Main() { 
    WebClient user = new WebClient(); 
    string uri = "http://www.navioo.com"; 
    string fname = "data.txt"; 
     
    try { 
      Console.WriteLine("Downloading data from " + 
                        uri + " to " + fname); 
      user.DownloadFile(uri, fname); 
    } catch (WebException exc) { 
      Console.WriteLine(exc); 
    } catch (UriFormatException exc) { 
      Console.WriteLine(exc); 
    } 
      
    Console.WriteLine("Download complete."); 
  } 
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Network
» Web Client