|
-
Feb 15th, 2011, 11:46 PM
#1
Thread Starter
Member
[RESOLVED] File path format not supported?
I keep getting the annoying error for the following code:
Code:
Dim user As String
user = Environ$("USERPROFILE")
My.Computer.Network.DownloadFile _
("WorldBackup 1.0.0.4.zip", _
"C:\Users\" & user & "\Desktop")
And I can't seem to figure out why. :/
Last edited by SRBuckey5266; Mar 8th, 2013 at 10:59 PM.
-
Feb 15th, 2011, 11:52 PM
#2
Re: File path format not supported?
-
Feb 15th, 2011, 11:54 PM
#3
Thread Starter
Member
Re: File path format not supported?
 Originally Posted by formlesstree4
...what is the error?
The error is the title of the thread. :P
-
Feb 15th, 2011, 11:55 PM
#4
Re: File path format not supported?
I was hoping for a stack trace that would actually show what 'user' is when plugged into the path. It gives more information.
What does user actually evaluate to be?
-
Feb 15th, 2011, 11:59 PM
#5
Thread Starter
Member
Re: File path format not supported?
 Originally Posted by formlesstree4
I was hoping for a stack trace that would actually show what 'user' is when plugged into the path. It gives more information.
What does user actually evaluate to be?
What do you mean? It's:
Code:
Dim user As String
user = Environ$("USERPROFILE")
And it would as the following:
C:\Users\Justin\
---------user
It grabs the person's computer username to get the correct path.
-
Feb 16th, 2011, 12:03 AM
#6
Re: File path format not supported?
Obviously something isn't right. Put a breakpoint and make sure that's what actually is happening.
-
Feb 16th, 2011, 12:16 AM
#7
Thread Starter
Member
Re: File path format not supported?
 Originally Posted by formlesstree4
Obviously something isn't right. Put a breakpoint and make sure that's what actually is happening.
Thanks, that did the trick.
Apparently it was doing C:\UsersC:\Users\Justin\Desktop
:P
-
Feb 16th, 2011, 12:20 AM
#8
Re: File path format not supported?
 Originally Posted by SRBuckey5266
Thanks, that did the trick.
Apparently it was doing C:\UsersC:\Users\Justin\Desktop
:P
Please mark the thread as resolved if that's all there is.
-
Feb 16th, 2011, 12:25 AM
#9
Thread Starter
Member
Re: File path format not supported?
Well, I ran into the following error:
destinationFileName needs to include a file name.
For the following code:
Code:
Dim user As String
user = Environ$("USERPROFILE")
MsgBox(user & "\Desktop")
My.Computer.Network.DownloadFile("http://www.minecraftservers.comyr.com/WorldBackup.exe", user & "\Desktop")
Process.Start("C:\WorldBackup.exe")
-
Feb 16th, 2011, 12:27 AM
#10
Re: File path format not supported?
You need to put a filename then:
Code:
My.Computer.Network.DownloadFile("http://www.minecraftservers.comyr.com/WorldBackup.exe", user & "\Desktop\filename.exe")
-
Feb 16th, 2011, 12:33 AM
#11
Re: File path format not supported?
First up, as this issue has demonstrated, always confirm that you are using the data that you think you are, especially when things don't work the way you expect. Don't just assume that field has a particular value. Look at the actual value and make sure that it is what you expect.
Second, don't use Environ. It's a VB6 holdover. Use Envirnoment.GetEnvironmentVariable to get an environment variable in VB.NET.
Finally, don't use environment variables if you can avoid it, which you can in this case. If you want the path of the current user's desktop folder then use My.Computer.FileSystem.SpecialDirectories.Desktop or Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|