Support Forums
[Visual Basic] FTP Uploader [Tutorial] - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: [Visual Basic] FTP Uploader [Tutorial] (/showthread.php?tid=19878)



[Visual Basic] FTP Uploader [Tutorial] - Coding Support - 06-23-2011

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



RE: [Visual Basic] FTP Uploader [Tutorial] - Slurms Makenzi - 06-23-2011

Good tutorial, this can be used to make something like gyazo, which i'm doing.


RE: [Visual Basic] FTP Uploader [Tutorial] - Black Ghost - 06-29-2011

Very nice tutorial!
Maybe a picture of what it should look like would be helpful Smile


RE: [Visual Basic] FTP Uploader [Tutorial] - Injection - 06-29-2011

nice man gonna use very soon


RE: [Visual Basic] FTP Uploader [Tutorial] - Firetech - 06-29-2011

Can't download it could you upload it again Smile


RE: [Visual Basic] FTP Uploader [Tutorial] - Injection - 06-29-2011

cant download anymore can you please reupload


RE: [Visual Basic] FTP Uploader [Tutorial] - Kenneth - 08-12-2012

Awesome Share. c:
Blackhat Thumbsup