【发布时间】:2017-01-06 14:06:32
【问题描述】:
我正在尝试在 FTP 服务器上创建一个文件,但我所拥有的只是一个字符串或数据流以及创建它时应使用的文件名。有没有办法从流或字符串在服务器上创建文件(我没有创建本地文件的权限)?
string location = "ftp://xxx.xxx.xxx.xxx:21/TestLocation/Test.csv";
WebRequest ftpRequest = WebRequest.Create(location);
ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;
ftpRequest.Credentials = new NetworkCredential(userName, password);
string data = csv.getData();
MemoryStream stream = csv.getStream();
//Magic
using (var response = (FtpWebResponse)ftpRequest.GetResponse()) { }
【问题讨论】:
标签: c# .net ftp webrequest ftpwebrequest