Support Forums

Full Version: [Visual Basic] FTP Uploader [Tutorial]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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...




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...

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...

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...




I TAKE NOT CREDIT FOR THIS CODE. SIMPLY SHARING w/ YOU GUYS
Good tutorial, this can be used to make something like gyazo, which i'm doing.
Very nice tutorial!
Maybe a picture of what it should look like would be helpful Smile
nice man gonna use very soon
Can't download it could you upload it again Smile
cant download anymore can you please reupload
Awesome Share. c:
Blackhat Thumbsup