Results 1 to 11 of 11

Thread: [RESOLVED] File path format not supported?

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2009
    Posts
    53

    Resolved [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.

  2. #2

    Re: File path format not supported?

    ...what is the error?

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2009
    Posts
    53

    Re: File path format not supported?

    Quote Originally Posted by formlesstree4 View Post
    ...what is the error?
    The error is the title of the thread. :P

  4. #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?

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2009
    Posts
    53

    Re: File path format not supported?

    Quote Originally Posted by formlesstree4 View Post
    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.

  6. #6

    Re: File path format not supported?

    Obviously something isn't right. Put a breakpoint and make sure that's what actually is happening.

  7. #7

    Thread Starter
    Member
    Join Date
    Mar 2009
    Posts
    53

    Re: File path format not supported?

    Quote Originally Posted by formlesstree4 View Post
    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

  8. #8

    Re: File path format not supported?

    Quote Originally Posted by SRBuckey5266 View Post
    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.

  9. #9

    Thread Starter
    Member
    Join Date
    Mar 2009
    Posts
    53

    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")

  10. #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")

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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).
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width