Results 1 to 5 of 5

Thread: [RESOLVED] Path to Desktop

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Location
    Uk
    Posts
    157

    Resolved [RESOLVED] Path to Desktop

    I want to move a file from the users desktop to the running applications folder.
    This is what i have which works for me - but the desktop path will be different for each user so am looking for the system path

    Code:
        Dim FileToMove As String
            Dim MoveLocation As String
           
            FileToMove = "c:\users\me\desktop\test.txt"
            MoveLocation = "c:\TestFolder\test2.txt"
           
            If System.IO.File.Exists(FileToMove) = True Then
                System.IO.File.Move(FileToMove, MoveLocation)
                MsgBox("file moved")
                Close()
            Else
                MessageBox.Show("file not found. Please check that the file is saved to your desktop and it is called test.txt")
            End If

  2. #2
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Re: Path to Desktop

    Code:
    My.Computer.FileSystem.SpecialDirectories.Desktop
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Location
    Uk
    Posts
    157

    Re: Path to Desktop

    Cant get that to work
    tried
    Code:
    FileToMove = My.Computer.FileSystem.SpecialDirectories.Desktop \ "test.txt"
    FileToMove = "My.Computer.FileSystem.SpecialDirectories.Desktop\test.txt"
    FileToMove = "My.Computer.FileSystem.SpecialDirectories.Desktop.test.txt"

  4. #4
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Re: Path to Desktop

    No, use this:

    Code:
    FileToMove = My.Computer.FileSystem.SpecialDirectories.Desktop & "\test.txt"
    Use the ampersand '&' to concatenate two or more strings together.
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Location
    Uk
    Posts
    157

    Re: Path to Desktop

    Superb mate - that did it
    Thanks for your help

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