實(shí)例如下:
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服務(wù) /// </ 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) { ///錯(cuò)誤信息處理 } return returnPath; } |
以上這篇c# FTP上傳文件實(shí)例代碼(簡(jiǎn)易版)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持服務(wù)器之家。
原文鏈接:http://www.cnblogs.com/hanzhecheng/archive/2017/12/05/7988570.html