Hello, I currently have been coding this.
Imports System.IO
Imports System.IO.Compression
Imports System.Windows.Forms
Imports System
Imports Ionic.Zip
Imports System.IO.Path
Imports System.Net.WebException
Imports System.Net
Imports System.Text
Imports System.Net.Sockets
Imports System.Security.Cryptography
Public Class Main
' FTP upload
Private Sub FTPU()
If ListBox2.SelectedItem = Nothing Then
MsgBox("Select world.")
Else
Dim clsRequest As System.Net.FtpWebRequest = _
DirectCast(System.Net.WebRequest.Create("ftp://127.0.0.1" & "example.zip"), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential(UserNameBox.Text, PasswordBox.Text)
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes(c:\Example.txt)
' upload file...
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
FTPU()
End If
End Sub
'FTP download
Private Sub FTPS()
Dim line As String
Dim ftpWebReq As Net.FtpWebRequest = CType(Net.WebRequest.Create("ftp://127.0.0.1"), Net.FtpWebRequest)
ftpWebReq.Method = Net.WebRequestMethods.Ftp.ListDirectory
ftpWebReq.Credentials = New Net.NetworkCredential(UserNameBox.Text, PasswordBox.Text)
Dim ftpWebResp As Net.FtpWebResponse = CType(ftpWebReq.GetResponse(), Net.FtpWebResponse)
Dim streamer As IO.Stream = ftpWebResp.GetResponseStream()
Dim reader As New IO.StreamReader(streamer)
' Read first line.
line = reader.ReadLine
' Loop over each line in file, While list is Not Nothing.
Do While (Not line Is Nothing)
' Add this line to list.
Me.ListBox1.Items.Add(line)
' Display to console.
Console.WriteLine(line)
' Read in the next line.
line = reader.ReadLine
Loop
reader.Close()
'clean up
line = ""
ftpWebReq = Nothing
streamer = Nothing
reader = Nothing
End Sub
End Class
It uploads files fine.
But, I want to have the UsernameBox.text and PasswordBox.text on another form, so if the login fails, then it exits the application.
If login is successful, then form2 loads and they can press the upload button.
Sorry if I'm being vague, its 5:30am.
Thank you and again, sorry.