VB icon

File Download

Email
Submitted on: 1/2/2015 12:33:00 AM
By: LinSparkUx7 (from psc cd)  
Level: Beginner
User Rating: By 8 Users
Compatibility: C#, VB.NET
Views: 1354
 
     This shows how to download a file in VB.NET and C# in only 2 lines of code! This is meant for BEGINNERS, but all are welcome to see it. I know this isn't much code, in fact, not event much of anything at all, but I was desperately trying to find a way to download a file with nonprintable characters (such as EXE's or DLL's), but when I tried using streams, it wouldn't come out quite right. Finally, I found a way to do this, so I am sharing it with everybody else in case someone need it also.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: File Download
// Description:This shows how to download a file in VB.NET and C# in only 2 lines of code! This is meant for BEGINNERS, but all are welcome to see it. I know this isn't much code, in fact, not event much of anything at all, but I was desperately trying to find a way to download a file with nonprintable characters (such as EXE's or DLL's), but when I tried using streams, it wouldn't come out quite right. Finally, I found a way to do this, so I am sharing it with everybody else in case someone need it also.
// By: LinSparkUx7 (from psc cd)
//
// Assumes:Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family
//**************************************

'[Visual Basic]
'<ComVisible(True)>
'Public Sub DownloadFile( _
' ByVal address As String, _
' ByVal fileName As String _
')
 
Dim myWebClient As New System.Net.WebClient()
myWebClient.DownloadFile("http://www.google.com/images/logo.gif", "C:\GoogleLogo.gif")
'The code above downloads the google logo into the root directory of the C drive.
 
'[C#]
'[ComVisible(true)]
'public void DownloadFile(
' string address,
' string fileName
');
 
System.Net.WebClient myWebClient = new System.Net.WebClient();
myWebClient.DownloadFile("http://www.google.com/images/logo.gif","C:\GoogleLogo.gif");
'The code above downloads the google logo into the root directory of the C drive.


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.