C# FTP上传txt文件出现远程服务器返回错误: (550) 文件不可用(例如,未找到文件,无法访问文件)
监控到fileName是D:\\test\\test\\bin\\Debug\\Data\\000077_20121001.txt, string uploadUrl是ftp://192.168.1.200/000077_20121001.txtprivate void UploadFun(string fileName, string uploadUrl)//FtpStatusCode
{
Stream requestStream = null;
FileStream fileStream = null;
FtpWebResponse uploadResponse = null;
FtpWebRequest uploadRequest =
(FtpWebRequest)WebRequest.Create(new Uri(uploadUrl));
uploadRequest.Method = WebRequestMethods.Ftp.UploadFile;
uploadRequest.Proxy = null;
uploadRequest.Credentials = new NetworkCredential(“ftp”, "123456");
uploadRequest.KeepAlive = false;
uploadRequest.Method = WebRequestMethods.Ftp.UploadFile;
uploadRequest.UseBinary = true;
requestStream = uploadRequest.GetRequestStream();
fileStream = File.Open(fileName, FileMode.Open);
byte[] buffer = new byte[1024];
int bytesRead;
while (true)
{
bytesRead = fileStream.Read(buffer, 0, buffer.Length);
if (bytesRead == 0)
break;
requestStream.Write(buffer, 0, bytesRead);
}
requestStream.Close();
uploadResponse = (FtpWebResponse)uploadRequest.GetResponse();
}
问题如题,请教高手帮忙看下是哪里的问题,谢谢指点。
补充:.NET技术 , C#