Jump to content
Xtreme .Net Talk

FTP Query


Recommended Posts

Guest double-helix
Posted
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 :)
  • 3 weeks later...
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...