[HELP] Download and replace file

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts Page 1 of 1
Contributors
User avatar
code it
VIP - Site Partner
VIP - Site Partner
Posts: 821
Joined: Sun Oct 10, 2010 3:02 pm

[HELP] Download and replace file
code it
hi i got this code
My.Computer.Network.DownloadFile("", "" )

how do i make it replace the file because it gives me errors if the file already exsists, can i make it so it downlods and replace that file, please help
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

With the same code you have more options, you have the server username and password from the server you are downloading the file, showUI, timeout and overwrite.
Code: Select all
My.Computer.Network.DownloadFile("download location", "where you want to save it", "user", "pass", False, 100, True)
http://msdn.microsoft.com/en-us/library ... 90%29.aspx
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
code it
VIP - Site Partner
VIP - Site Partner
Posts: 821
Joined: Sun Oct 10, 2010 3:02 pm

thanks ill try it out
User avatar
code it
VIP - Site Partner
VIP - Site Partner
Posts: 821
Joined: Sun Oct 10, 2010 3:02 pm

do i have to put a user, pass because it downloaded files earlier without a user and pass?
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

You could just put , , instead of using a user and a pass and leave it blank, look in Visual studio if it says in the description that comes up when you type "Username" above your code just put , then it will change to pass then put , then it will say Show UI you can just put True or False it gives a description as you're typing the code out
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
code it
VIP - Site Partner
VIP - Site Partner
Posts: 821
Joined: Sun Oct 10, 2010 3:02 pm

i tried this and it gave me errors i also tried doing "", "" also errors
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

This should work:
Code: Select all
 My.Computer.Network.DownloadFile("download location", "where you want to save it", "", "", False, 100, True)
The "", "" is user and pass default value, the False is showUI and 100 is connection timeout default and True is to overwrite the file
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
code it
VIP - Site Partner
VIP - Site Partner
Posts: 821
Joined: Sun Oct 10, 2010 3:02 pm

EDIT: how do i add a progress bar to it?
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

I haven't done that for awhile sorry you will need someone else to help.

Is it replacing the file now though?
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
code it
VIP - Site Partner
VIP - Site Partner
Posts: 821
Joined: Sun Oct 10, 2010 3:02 pm

Re: [HELP] Download and replace file
code it
Yes i had to change 100 to 9999
10 posts Page 1 of 1
Return to “Coding Help & Support”