Mega Code Archive

 
Categories / C# Book / 08 Net
 

0597 Using FTP

For simple FTP upload and download operations, you can use WebClient as we did previously: using System; using System.Net; using System.Threading; using System.IO; using System.Text; class ThreadTest { static void Main() { WebClient wc = new WebClient(); wc.Proxy = null; wc.Credentials = new NetworkCredential("nutshell", "yourValue"); wc.BaseAddress = "ftp://ftp.abc.com"; wc.UploadString("tempfile.txt", "hello!"); Console.WriteLine(wc.DownloadString("tempfile.txt")); // hello! } }