FTP Query

  • Thread starter Thread starter double-helix
  • Start date Start date
D

double-helix

Guest
hi, i was wondering, how would i go about making an ftp client in VB.NET? i can do it in vb6, with lotsa help, but its a bitof a mystery to me here. thanks for ne help u can give :)
 
HI ,
i have a Resultion for you. Use the Online Help for VS DOT NET.
Keywords : TCPClient. You got Information about different Classes. e.g Networkstream. You must import the Classes System.Net.Sockets and System.Text
*************************************************
Dim tcpClient As New TcpClient()

' Uses the GetStream public method to return the NetworkStream.
Try
tcpClient.Connect("HOSTNAME", 21) ' Verbindung herstellen

Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite Then
Dim sendBytes As [Byte]() = Encoding.UTF8.GetBytes("USRENAME")
networkStream.Write(sendBytes, 0, sendBytes.Length)
networkStream.Flush()

Dim sendBytes1 As [Byte]() = Encoding.UTF8.GetBytes("PASSWORD")
networkStream.Write(sendBytes1, 0, sendBytes.Length)
networkStream.Flush()

Else
'Console.WriteLine("You cannot write data to this stream.")
MessageBox.Show("You cannot write data to this stream.")
tcpClient.Close()
Return
End If
If networkStream.CanRead Then

' Reads the NetworkStream into a byte buffer.
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
' Read can return anything from 0 to numBytesToRead.
' This method blocks until at least one byte is read.
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

' Returns the data received from the host to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)
'Console.WriteLine(("This is what the host returned to you: " + returndata))
MessageBox.Show("This is what the host returned to you: " + returndata)

Else
'Console.WriteLine("You cannot read data from this stream.")
MessageBox.Show("You cannot read data from this stream.")
tcpClient.Close()
Return
End If
Catch e As Exception
'Console.WriteLine(e.ToString())
MessageBox.Show(e.ToString())
*************************************************
But my Code has a mistake. I can make a connect to the ftp server, but i can not login in. I searching for a resultion this time.
best regards from Germany
 
Back
Top