Problem sending commands to FTP server 
Author Message
 Problem sending commands to FTP server

The following fuction is ment to sent few commands to a ftp server, but it
doesn't. What's wrong ?
private void Button_Click(object sender, System.EventArgs e)

{

try

{

client = new TcpClient(hostName.Text,portNum);

NetworkStream ns = client.GetStream();

byte[] sendBytes = Encoding.ASCII.GetBytes("QUIT");

ns.Write( sendBytes,0,sendBytes.Length);

Quote:
}

catch (Exception e1)

{

ftpstatus.Text = e1.ToString();

Quote:
}

client.Close();
Quote:
}



Fri, 28 Jan 2005 19:12:32 GMT  
 Problem sending commands to FTP server
BiO,

    I believe that every command sequence sent to an FTP server requires the
control-feed/newline combo.  So, you should try encoding this:

// The command to send.
byte[] sendBytes = Encoding.ASCII.GetBytes("QUIT\r\n");

    Hope this helps.

--
               - Nicholas Paldino [.NET/C# MVP]

Quote:

> The following fuction is ment to sent few commands to a ftp server, but it
> doesn't. What's wrong ?
> private void Button_Click(object sender, System.EventArgs e)

> {

> try

> {

> client = new TcpClient(hostName.Text,portNum);

> NetworkStream ns = client.GetStream();

> byte[] sendBytes = Encoding.ASCII.GetBytes("QUIT");

> ns.Write( sendBytes,0,sendBytes.Length);

> }

> catch (Exception e1)

> {

> ftpstatus.Text = e1.ToString();

> }

> client.Close();

> }



Fri, 28 Jan 2005 20:15:39 GMT  
 Problem sending commands to FTP server
It works! Thank you!!!


Quote:
> BiO,

>     I believe that every command sequence sent to an FTP server requires
the
> control-feed/newline combo.  So, you should try encoding this:

> // The command to send.
> byte[] sendBytes = Encoding.ASCII.GetBytes("QUIT\r\n");

>     Hope this helps.

> --
>                - Nicholas Paldino [.NET/C# MVP]


> > The following fuction is ment to sent few commands to a ftp server, but
it
> > doesn't. What's wrong ?
> > private void Button_Click(object sender, System.EventArgs e)

> > {

> > try

> > {

> > client = new TcpClient(hostName.Text,portNum);

> > NetworkStream ns = client.GetStream();

> > byte[] sendBytes = Encoding.ASCII.GetBytes("QUIT");

> > ns.Write( sendBytes,0,sendBytes.Length);

> > }

> > catch (Exception e1)

> > {

> > ftpstatus.Text = e1.ToString();

> > }

> > client.Close();

> > }



Fri, 28 Jan 2005 20:39:23 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Sending messages to FTP client from FTP Server applications

2. Problem connecting to nntp server and sending commands

3. Ftp Command to send

4. Sending an FTP command with CFtpConn

5. FTP connection and command sending

6. How to issue a command to FTP server

7. PROBLEM: FTP through a proxy-server...

8. How do I send a chmod command to a ftp server?

9. How to send email using smtp server.(Problem)

10. ADO Command problem in EXE Com server

11. Sending info from server to client in SQL Server

12. Easy way to send files through FTP...

 

 
Powered by phpBB® Forum Software