当前位置:编程学习 > C#/ASP.NET >>

C# FTP上传txt文件出现远程服务器返回错误: (550) 文件不可用(例如,未找到文件,无法访问文件)

监控到fileName是D:\\test\\test\\bin\\Debug\\Data\\000077_20121001.txt, string uploadUrl是ftp://192.168.1.200/000077_20121001.txt        
private 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#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,