[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. :/
Re: File path format not supported?
Re: File path format not supported?
Quote:
Originally Posted by
formlesstree4
...what is the error?
The error is the title of the thread. :P
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?
Re: File path format not supported?
Quote:
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.
Re: File path format not supported?
Obviously something isn't right. Put a breakpoint and make sure that's what actually is happening.
Re: File path format not supported?
Quote:
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
Re: File path format not supported?
Quote:
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.
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")
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")
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).