简体   繁体   English

如何在C#中使用PORT ftp raw命令?

[英]How do I use PORT ftp raw command in c#?

I am trying to make a FTP client in c#. 我正在尝试在c#中创建一个FTP客户端。 I found a class that support basic FTP commands on http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.ftp_members.aspx . 我在http://msdn.microsoft.com/zh-cn/library/system.net.webrequestmethods.ftp_members.aspx上找到了一个支持基本FTP命令的类。

on the list, PORT command is missing. 在列表中,缺少PORT命令。

How do I use PORT command in c#? 如何在C#中使用PORT命令?

At first thought, I imagine that you specify the port in the URI that you use to connect: 乍一想,我想您在用于连接的URI中指定端口:

ftp://user:password@ftp.somesite.com:1234/

I know this doesn't encompass the entire functionality of the PORT command, but it's a start. 我知道这并不包含PORT命令的全部功能,但这只是一个开始。

Have you looked at the FtpWebRequest class? 您是否看过FtpWebRequest类? It is designed for FTP, rather then the general WebRequest class. 它是为FTP设计的,而不是常规的WebRequest类。

You can set the overriden Method property to PORT if needed. 如果需要,可以将重写的Method属性设置为PORT

Download, upload, append and list will do the PORT command for you automatically when negotiation endpoints. 协商端点时,下载,上传,追加和列出将自动为您执行PORT命令。 Unless you are writing your own FTP client you should not need to use this command. 除非您正在编写自己的FTP客户端,否则不需要使用此命令。

In active mode, the FTP server will connect to the client machine, and your PORT command needs to specify a port number the FTP server can connect to. 在活动模式下,FTP服务器将连接到客户端计算机,并且您的PORT命令需要指定FTP服务器可以连接到的端口号。

In passive mode, you connect to the FTP server. 在被动模式下,您连接到FTP服务器。 When you send the PASV command, the FTP server will respond with an address and port number you can connect to. 当您发送PASV命令时,FTP服务器将以您可以连接的地址和端口号进行响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM