| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 117209 | 2011-04-07 10:09:00 | Learning VB - Download Script | The Error Guy (14052) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 1192819 | 2011-04-07 10:09:00 | Hey guys. I have decided I have to stop relying on everyone else to code up all the fancy ideas I think of so I decided to start learning (again) Visual Basic. I want to create a script that will download a file from a URL through a proxy and save it to the computer. I have "tried" to use several scripts and failed miserably with each so I was wondering if someone could flip me in the right direction, so far I have: Module Module1 Sub Main() ' <summary> ' Function to download a file from URL and save it to local drive ' </summary> ' <param name="_URL">URL address to download file</param> End Sub Public Sub DownloadFile(ByVal _URL As String, ByVal _SaveAs As String) Try Dim _WebClient As New System.Net.WebClient() ' Downloads the resource with the specified URI to a local file. _WebClient.DownloadFile(_URL, _SaveAs) Catch _Exception As Exception ' Error Console.WriteLine("Exception caught in process: {0}", _Exception.ToString()) End Try End Sub End Module This is an unedited code snippet that I am obviously trying to implement in a way that won ' t work :p also, I have not included any proxy code since I couldn ' t find any What i ' d like to know is where to I put the URL http:\\randomsite.com\linktofile and the path for the save file E:\testupdate.exe Yes this is a horrible mess because I can ' t program for s*** and nothing makes sense like HTML or PHP which are the only other languages I know Cheers guys, I know (hope actually) you ' ll provide your usual helpful advice to a muppet such as oneself :D |
The Error Guy (14052) | ||
| 1192820 | 2011-04-08 00:28:00 | First off please forgive me if I am wrong and you already know this, but I thought since you have 0 replies I might as well try and help - even with my limited knowledge of VB :D What i'd like to know is where to I put the URL http:\\randomsite.com\linktofile and the path for the save file E:\testupdate.exe From what you say here it looks like you are having an issue calling the method which you have written with the right parameters (the URL and save path respectively) I would try something like this (as I said I have not used VB since high school 5 years ago, and even then it was pretty basic stuff) Public Sub StartDownload() //pointing the DownloadFile method to a place where it can get the url //and path strings DownloadFile(textBoxURL.text, textBoxPath.text) End Sub Now all you would have to do is add two text boxes to your form (Are you even using a form, if not this clearly isn't helpful :() as well as a button, double click the button in the GUI editor and add "StartDownload()" inside its sub. Hopefully this is helpful although I fear there might be some syntax errors or whatnot, hopefully I have identified where you were having an issue and you can mend my pseudo code to solve it. |
Fifthdawn (9467) | ||
| 1192821 | 2011-04-08 00:44:00 | These might help www.vbdotnetheaven.com www.digitalcoding.com |
bevy121 (117) | ||
| 1 | |||||