tags:

views:

156

answers:

3

Hi,

I am trying to make a FTP client in c#. I found a class that support basic FTP commands 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#?

A: 

At first thought, I imagine that you specify the port in the URI that you use to connect:

ftp://user:[email protected]:1234/

I know this doesn't encompass the entire functionality of the PORT command, but it's a start.

Jonathan
A: 

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.

Oded
A: 

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.

Dag
I am writing my own FTP client..that is why I need to use PORT command.
Moon
Sorry I wasn't clear. I meant writing your own FTP client from scratch, implementing the data/command channels yourself vs wrapping a class like FtpWebRequest with your own logic. I've written a FTP client from scratch using System.Net.Socket, but this was before a decent FTP client implementation was available for .NET.
Dag