Filezilla c#500语法错误,无法识别命令

Filezilla c#500语法错误,无法识别命令,c#,server,filezilla,C#,Server,Filezilla,我已经使用Filezilla创建了一个ftp服务器。我试图用c代码上传一个文件。我的cide是一个非常简单的函数,叫做上传: static void UploadFile(string filepath) { string m_FtpHost = "http://ip:port/"; string m_FtpUsername = "userID"; string m_FtpPassword = "pass"; // Get an instance

我已经使用Filezilla创建了一个ftp服务器。我试图用c代码上传一个文件。我的cide是一个非常简单的函数,叫做上传:

static void UploadFile(string filepath)
    {
     string m_FtpHost = "http://ip:port/";
     string m_FtpUsername = "userID";
     string m_FtpPassword = "pass";
     // Get an instance of WebClient
     WebClient client = new System.Net.WebClient();
     // parse the ftp host and file into a uri path for the upload
     Uri uri = new Uri(m_FtpHost + new FileInfo(filepath).Name);
     // set the username and password for the FTP server
     client.Credentials = new System.Net.NetworkCredential(m_FtpUsername, m_FtpPassword);
     // upload the file asynchronously, non-blocking.

     client.UploadFileAsync(uri, "STOR", filepath);
    }

    static void Main(string[] args)
    {
      UploadFile("file.pdf"); 
      Console.ReadKey();
    }
在Filezilla服务器gui中,我收到以下消息:

(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> STOR  /file.pdf HTTP/1.1
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> 530 Please log in with USER and PASS first.
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> Content-Type: application/octet-stream
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> 500 Syntax error, command unrecognized.
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> Host: ip:port
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> 500 Syntax error, command unrecognized.
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> Content-Length: 481868
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> 500 Syntax error, command unrecognized.
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> Expect: 100-continue
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> 500 Syntax error, command unrecognized.
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> Connection: Keep-Alive
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> 500 Syntax error, command unrecognized.
(000017)11/23/2015 10:47:19 AM - (not logged in) (ip)> disconnected.
你知道这里可能出了什么问题吗? 编辑:我试图在上传文件中用ftp更改http。现在我收到以下消息:

(000019)11/23/2015 10:59:53 AM - chrathan user (ip)> 257 "/" is current directory.
(000019)11/23/2015 10:59:53 AM - user (ip)> TYPE I
(000019)11/23/2015 10:59:53 AM - user (ip)> 200 Type set to I
(000019)11/23/2015 10:59:53 AM - user (ip)> PASV
(000019)11/23/2015 10:59:53 AM - user (ip)> 227 Entering Passive Mode (ip with comma)
(000019)11/23/2015 10:59:53 AM - user (ip)> STOR file.pdf
(000019)11/23/2015 10:59:53 AM - user (ip)> 150 Opening data channel for file upload to server of "/file.pdf"
(000019)11/23/2015 10:59:53 AM - user (ip)> 550 can't access file.
(000019)11/23/2015 10:59:53 AM - user (ip)> disconnected.

EDIT2:基本上,我尝试访问的文件夹是网络共享磁盘。当我在电脑中切换到本地文件夹时,一切正常。最后,我的问题是如何访问网络共享磁盘?

您的
m\u FtpHost
变量设置为使用http,它需要
ftp://ip:port/


这就是为什么日志的第一行显示:STOR/file.pdfHTTP/1.1

如何将WebRequest与WebRequestMethods.FTP.Put一起使用?登录过程似乎不起作用。服务器请求您的授权凭据,答案是内容类型,因此,使用正确的上载请求我将http更改为ftp,我现在收到新的错误消息。您尝试上载的文件夹是否对运行FileZilla服务器的帐户具有写入权限?基本上是一个网络共享驱动器,因此似乎不是那么简单。啊,我明白了。FileZilla论坛上的这篇关于设置FileZilla服务器以使用网络共享的贴子可能会对您有所帮助:因此,实际上link建议在我的windows中创建一个新用户,并使用它来运行FileZilla服务器服务。我说的对吗?这取决于您的特定环境/域等。您不一定需要新帐户,您可以使用现有帐户,但从管理角度来看,建议为此目的使用专用帐户。重要的一点是,运行FileZilla的本地服务器帐户和连接到的远程网络共享都需要授予正确的权限。