Hi everyone,
Can you help me please? I am trying to login into to an FTP server. I
can successfully reach the server and it sends me a welcome message
but after that I don't know how to send down the username, password
etc...It identifies itself as: "Pure-FTPd"
Is there any way I can find out this by asking the server in some way
as to the format that it accepts? Do you know what I mean? Any
suggestions/comments/useful code samples/advice would be most
appreciated.
Thanks in advance,
Al
**** CODE AS FOLLOWS ****
System.Net.Sockets.TcpClient mtTCPClient = new
System.Net.Sockets.TcpClient(FTPUrl, portNo);
System.Net.Sockets.NetworkStream myNS = mtTCPClient.GetStream();
//2. Read something
if (myNS.CanRead )
{
byte[] myReadBuffer = new byte[1024];
String myCompleteMessage = "";
int numberOfBytesRead = 0;
// Incoming message may be larger than the buffer size.
do
{
numberOfBytesRead = myNS.Read(myReadBuffer, 0,
myReadBuffer.Length);
myCompleteMessage = String.Concat(myCompleteMessage,
System.Text.Encoding.ASCII.GetString(myReadBuffer, 0,
numberOfBytesRead));
}
while(myNS.DataAvailable);
}
**** END CODE ****
Peter Morris - 11 Mar 2008 15:47 GMT
It's a protocol, so it should be the same for all servers. If you need it
to be easier try some FTP components, rebex for example.
Jon Skeet [C# MVP] - 11 Mar 2008 15:54 GMT
> Can you help me please? I am trying to login into to an FTP server. I
> can successfully reach the server and it sends me a welcome message
[quoted text clipped - 5 lines]
> suggestions/comments/useful code samples/advice would be most
> appreciated.
You look at the RFC for FTP:
http://www.faqs.org/rfcs/rfc959.html

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Arne Vajhøj - 12 Mar 2008 02:41 GMT
> Can you help me please? I am trying to login into to an FTP server. I
> can successfully reach the server and it sends me a welcome message
[quoted text clipped - 5 lines]
> suggestions/comments/useful code samples/advice would be most
> appreciated.
First: are you sure that you can not use the builtin classes
in .NET since version 2.0: FtpWebRequest/Response ?
Secondly: the FTP protocol is a bit tricky (at least more
than HTTP, SMTP etc.). You can start studying the FTP RFC.
I also have some code I created for .NET 1.1 to have FTP and
still use on newer .NET versions if the builtin does not
work as I want it. IF you are interested I can post a link.
Arne
Cuong - 12 Mar 2008 17:19 GMT
> > Can you help me please? I am trying to login into to an FTP server. I
> > can successfully reach the server and it sends me a welcome message
[quoted text clipped - 16 lines]
>
> Arne
Could you post the link? I would like to take a look....
Thanks!
Arne Vajhøj - 13 Mar 2008 03:08 GMT
>> Secondly: the FTP protocol is a bit tricky (at least more
>> than HTTP, SMTP etc.). You can start studying the FTP RFC.
[quoted text clipped - 3 lines]
>
> Could you post the link? I would like to take a look....
http://www.vajhoej.dk/arne/eksperten/div_2007_04/xftp.cs
Arne
Cuong - 13 Mar 2008 16:11 GMT
> >> Secondly: the FTP protocol is a bit tricky (at least more
> >> than HTTP, SMTP etc.). You can start studying the FTP RFC.
[quoted text clipped - 7 lines]
>
> Arne
Thank you!