我正在尝试将文本文件从本地计算机传输到ftp服务器路径
var url= "ftpurl/file.txt";
var FTPUserName = username;
var FTPPassword = password;
var request = (FtpWebRequest)WebRequest.Create(url);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(FTPUserName,FTPPassword);
request.UseBinary = true;
request.KeepAlive = true;
var sourceStream = new StreamReader(@"C:\file.txt");
var fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
var requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse uploadResponse = (FtpWebResponse)request.GetResponse();
var value = uploadResponse.StatusDescription;
uploadResponse.Close();
“上传响应”将状态描述显示为“ 226传输完成”。 但是我在所需的ftp路径中看不到file.txt文件。你们能帮忙找出我哪里出了问题。预先感谢