C#FTP上传访问被拒绝错误550

时间:2012-01-17 16:32:02

标签: c# ftpwebrequest

My Class FTP在我的FTP服务器上工作正常,但与我的客户端FTP服务器无关。

public class UploadToFTP
    {
        public void UploadFTP(string LeSource, string Desti, string CodeClient)
        {
           Pers_Conf oConf =  LeConf.Get_Config(CodeClient);


         // Get the object used to communicate with the server.
           FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://" + oConf.FtpServer + oConf.FtpChemin +"/" + Desti);

            request.Method = WebRequestMethods.Ftp.UploadFile;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential(oConf.FtpLogin, oConf.FtpPwd);



            request.UseBinary = true;
            request.UsePassive = true;


            // Copy the contents of the file to the request stream.
            StreamReader sourceStream = new StreamReader(LeSource);
            byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
            sourceStream.Close();
            request.ContentLength = fileContents.Length;


            Stream requestStream = request.GetRequestStream();
            requestStream.Write(fileContents, 0, fileContents.Length);
            requestStream.Close();

            FtpWebResponse response = (FtpWebResponse)request.GetResponse();

            //Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);

            response.Close();
        }
    }

此行不起作用:Stream requestStream = request.GetRequestStream();

有人有解决方案吗? 我已将权利改为777。

提前谢谢你, 甜菊

1 个答案:

答案 0 :(得分:1)

The Solutions

/只能运行几个ftp服务器,但//它在任何地方都能正常运行