FtpClient类下载 :FtpClient.zip
客户端使用:
第一种使用WebClient
private void ftp_op1()
{
WebClient wc = new WebClient();
//wc.Credentials = new NetworkCredential("pkm", "123456");//没有加就是匿名用户
wc.DownloadFile("ftp://127.0.0.1/test.txt", "c:/test.txt");
// MessageBox.Show("文件(test.txt)下载成功!");
wc.UploadFile(ftp://127.0.0.1/test.txt, "c:/test.txt"); //要有上传权限!
}
第二种使用FtpClient
private void ftp_op2()
{
FtpClient fc = new FtpClient("127.0.0.1", "pkm", "123456");
fc.Download("test.txt", "c:/test" + DateTime.Now.ToString("yyyy_MM_dd").Replace(" ", "") + ".txt");
}