WebClient上传文件至FTP
var client = new WebClient(); //ftp地址 client.BaseAddress = @"ftp://192.168.999.999"; //用户名密码 client.Credentials = new NetworkCredential("user100", "123456"); //上传ftp路径 string ftpPath = "ftp://192.168.999.999/tsk/ink/libing/2.txt";
try { //此处注意, //ftpPath参数,一定要指定文件名,不然报错
//达到的效果就是111.txt的内容会替换2.txt的内容 client.UploadFile(ftpPath,"E:\\FileTest\\111.txt"); } catch (Exception ex) { Console.WriteLine(ex.Message); }