实例如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/// < summary > /// 上传ftp服务 /// </ summary > /// < param name = "path" >文件地址</ param > /// < returns ></ returns > public string Upload(string path) { var client = new WebClient(); client.Credentials = new NetworkCredential("fptuser", "ftppwd");//用户名和密码 client.BaseAddress = "ftpurl";//ftp地址 string ftpPath = client.BaseAddress + "/TestFileUpLoad/" + Guid.NewGuid();//上传fptp路径 string returnPath = ""; try { client.UploadFile(ftpPath, path); returnPath = ftpPath; } catch (Exception ex) { ///错误信息处理 } return returnPath; } |
以上这篇c# FTP上传文件实例代码(简易版)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:http://www.cnblogs.com/hanzhecheng/archive/2017/12/05/7988570.html