06-23-2011, 07:58 PM
(This post was last modified: 12-29-2012, 07:10 PM by Coding Support.)
Step One
-Okay, lets design the GUI. Now in this tutorial i will be making the program upload a simple text file so go ahead and make a text file named tests and put it on your desktop. After that, design your GUI and make it look similar to mine. Here is mine...
My GUI (Click to View)
Step Two
-Step Two will be to add an openfiledialog, and to code the "Browse..." Button.
-Add the openfiledialog and make it whatever you want for the filter. I am doing text files so i will make it Text File(*.txt)|*.txt|All Files|*.*
-Once that is done, double click the Browse button and copy and paste this code for it...
-Add the openfiledialog and make it whatever you want for the filter. I am doing text files so i will make it Text File(*.txt)|*.txt|All Files|*.*
-Once that is done, double click the Browse button and copy and paste this code for it...
Code:
OpenFileDialog1.ShowDialog()
TextBox1.Text = OpenFileDialog1.FileName
Step Three
-In this step we will code the hardest part of the program, the "Upload" button. For the sake of this tutorial, just copy and paste my code. Or you can type it out, up to you.
-Double click the Upload button and use this code for it...
-Double click the Upload button and use this code for it...
Code:
Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("Your FTP Server Here"), System.Net.FtpWebRequest)
request.Credentials = New System.Net.NetworkCredential("user", "pass")
request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Dim file() As Byte = System.IO.File.ReadAllBytes(TextBox1.Text)
Dim st As System.IO.Stream = request.GetRequestStream()
st.Write(file, 0, file.Length)
st.Close()
st.Dispose()
-You will need to change the info to the server and the credentials to match your own FTP information. But now simply code the "Exit..." button by using Me.Close() and now you are done! Debug to test and save.
Our final code (Click to View)
Still having trouble? Download my source code here...
Source: FTP Uploads.rar
I TAKE NOT CREDIT FOR THIS CODE. SIMPLY SHARING w/ YOU GUYS