I am trying to create an FTP application using TCPClient. The code below attempts to log on to a FTP server. I have set up my machine to work as a server and i am using the code below to gain access to the files and folders. However, i keep getting an error message on the "MainForm.NetStrm = clientSocket.GetStream()" line saying that Object Reference has not been set to an instance of an object.
I declared the NetStrm variable as Networkstream but i cannot declare NetStrm as new NetworkStream.
Any ideas of what i am doing wrong? Thanks
Dim clientSocket As New TcpClient
MainForm.NetStrm = clientSocket.GetStream()
Dim RdStrm As StreamReader = New StreamReader(MainForm.NetStrm)
txtStatus.Text = RdStrm.ReadLine
txtStatus.Text = MainForm.sendFTPcmd("User " + txtUserName.Text + vbCrLf)
txtStatus.Text = MainForm.sendFTPcmd("Pass " + txtPassword.Text + vbCrLf)
If txtStatus.Text.Substring(0, 3) <> "230" Then
MessageBox.Show("Failed to log in")
MainForm.Server = txtServer.Text
MainForm.Text += "[Logged in]"
Visible = False