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

Filezilla c# 500 Syntax error, command unrecognized

我已经使用 Filezilla 创建了一个 ftp 服务器。我正在尝试使用 c# 代码上传单个文件。我的 cide 很简单,一个叫做 upload:

的函数
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 服务器图形用户界面中,我收到以下消息:

(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.

知道这里可能出了什么问题吗? 编辑:我试图在 UploadFile 中用 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_FtpHost 变量设置为使用 http,需要 ftp://ip:port/

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