How do I use PORT ftp raw command in c#?
I am trying to make a FTP client in c#. I found a class that support basic FTP comman开发者_StackOverflow中文版ds on http://msdn.microsoft.com/en-us/library/system.net.webrequestmethods.ftp_members.aspx.
on the list, PORT command is missing.
How do I use PORT command in c#?
Have you looked at the FtpWebRequest
class? It is designed for FTP, rather then the general WebRequest
class.
You can set the overriden Method
property to PORT
if needed.
At first thought, I imagine that you specify the port in the URI that you use to connect:
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.
Download, upload, append and list will do the PORT command for you automatically when negotiation endpoints. Unless you are writing your own FTP client you should not need to use this command.
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.
In passive mode, you connect to the FTP server. When you send the PASV command, the FTP server will respond with an address and port number you can connect to.
精彩评论