Results 1 to 7 of 7

Thread: [RESOLVED] Folder not found

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Resolved [RESOLVED] Folder not found

    I have a backup program scheduled to run every night at 1 A.M. which copies my documents as well as some other relevant folders to an external disk. It's based on the fso, the file system object.

    It reads various source and corresponding destination directory names from a text file. It jhas been working like a charm for more than one year now but I ran into trouble when I recently installed Windows 7. After I updated the names of the folders, all of them were copied as expected except one: "c:\Users\MyName\Documents" which gave an error (not found). My question is: I have noticed this folder is sometimes listed as "Documents" and sometimes as "My Documents" so I wonder exactly what name I should use.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Folder not found

    What does this question have to do with Visual Basic 6.0?

    Edit:

    If you need to check whether or not a file/folder exists in VB6.0 checkout Ellis Dee's code here.
    Last edited by Nightwalker83; Oct 14th, 2011 at 06:12 AM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Folder not found

    This should return the path of My Documents (which is classified as a "special folder")
    vb Code:
    1. Option Explicit
    2.  
    3. Private Const CSIDL_DOCUMENTS = 5 '// My Documents
    4. 'other possibilities for special folders are
    5. 'Private Const CSIDL_DESKTOP = &H0 '// The Desktop - virtual folder
    6. 'Private Const CSIDL_PROGRAMS = 2 '// Program Files
    7. 'Private Const CSIDL_CONTROLS = 3 '// Control Panel - virtual folder
    8. 'Private Const CSIDL_PRINTERS = 4 '// Printers - virtual folder
    9. 'Private Const CSIDL_FAVORITES = 6 '// Favourites
    10. 'Private Const CSIDL_STARTUP = 7 '// Startup Folder
    11. 'Private Const CSIDL_RECENT = 8 '// Recent Documents
    12. 'Private Const CSIDL_SENDTO = 9 '// Send To Folder
    13. 'Private Const CSIDL_BITBUCKET = 10 '// Recycle Bin - virtual folder
    14. 'Private Const CSIDL_STARTMENU = 11 '// Start Menu
    15. 'Private Const CSIDL_DESKTOPFOLDER = 16 '// Desktop folder
    16. 'Private Const CSIDL_DRIVES = 17 '// My Computer - virtual folder
    17. 'Private Const CSIDL_NETWORK = 18 '// Network Neighbourhood - virtual folder
    18. 'Private Const CSIDL_NETHOOD = 19 '// NetHood Folder
    19. 'Private Const CSIDL_FONTS = 20 '// Fonts folder
    20. 'Private Const CSIDL_SHELLNEW = 21 '// ShellNew folder
    21.  
    22. Private Const MAX_PATH As Integer = 260
    23.  
    24. Private Type SPITEMID
    25.     cb As Long
    26.     abID As Byte
    27. End Type
    28.  
    29. Private Type ITEMIDLIST
    30.     mkid As SPITEMID
    31. End Type
    32.  
    33. Private Declare Function SHGetSpecialFolderLocation Lib "Shell32.dll" _
    34. (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
    35.  
    36. Private Declare Function SHGetPathFromIDList Lib "Shell32.dll" _
    37. Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
    38.  
    39. Private Function GetSpecialFolderPath(CSIDL As Long) As String
    40. Dim sPath As String
    41. Dim IDL As ITEMIDLIST
    42. '
    43. ' Retrieve info about system folders such as the "Recent Documents" folder.
    44. ' Info is stored in the IDL structure.
    45. '
    46. fGetSpecialFolder = ""
    47. If SHGetSpecialFolderLocation(Form1.hwnd, CSIDL, IDL) = 0 Then
    48.     '
    49.     ' Get the path from the ID list, and return the folder.
    50.     '
    51.     sPath = Space$(MAX_PATH)
    52.     If SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) Then
    53.         GetSpecialFolderPath = Left$(sPath, InStr(sPath, vbNullChar) - 1) & "\"
    54.     End If
    55. End If
    56. End Function
    57.  
    58. Private Sub Command1_Click()
    59. Dim strLocation As String
    60. strLocation = GetSpecialFolderPath(CSIDL_DOCUMENTS)
    61. MsgBox strLocation
    62. End Sub

  4. #4

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Folder not found

    Quote Originally Posted by Nightwalker83 View Post
    What does this question have to do with Visual Basic 6.0?
    I made the program in VB6 and got some help from this forum so I posted this here off the top of my head due to routine.
    @administrators: please do move the post to the relevant forum.
    Quote Originally Posted by Nightwalker83 View Post
    Edit:

    If you need to check whether or not a file/folder exists in VB6.0 checkout Ellis Dee's code here.
    No, that's easy to do with the fso or other methods, the problem is the folder does actually exist but is not found.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  5. #5

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Folder not found

    Quote Originally Posted by Hack View Post
    This should return the path of My Documents (which is classified as a "special folder")...
    Thanks, I'll try this as soon as I can get to my home computer.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Folder not found

    Quote Originally Posted by krtxmrtz View Post
    @administrators: please do move the post to the relevant forum.
    This is the relevent forums section (if it were not it would be moved regardless of location preference)

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Folder not found

    Quote Originally Posted by krtxmrtz View Post
    Thanks, I'll try this as soon as I can get to my home computer.
    Strange, the documents folder reported by your code is the same I use in my program. I guess I'll have to make a more efficient error handling system, for the error reported when trying to open the documents folder may actually have been fired by some error in a subfolder. Of course, this makes it more difficult to catch.

    At any rate the question about the correct name has been answered so I mark the thread resolved.

    Thank you.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

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