|
-
Oct 14th, 2011, 05:47 AM
#1
[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)
-
Oct 14th, 2011, 06:02 AM
#2
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
-
Oct 14th, 2011, 06:39 AM
#3
Re: Folder not found
This should return the path of My Documents (which is classified as a "special folder")
vb Code:
Option Explicit
Private Const CSIDL_DOCUMENTS = 5 '// My Documents
'other possibilities for special folders are
'Private Const CSIDL_DESKTOP = &H0 '// The Desktop - virtual folder
'Private Const CSIDL_PROGRAMS = 2 '// Program Files
'Private Const CSIDL_CONTROLS = 3 '// Control Panel - virtual folder
'Private Const CSIDL_PRINTERS = 4 '// Printers - virtual folder
'Private Const CSIDL_FAVORITES = 6 '// Favourites
'Private Const CSIDL_STARTUP = 7 '// Startup Folder
'Private Const CSIDL_RECENT = 8 '// Recent Documents
'Private Const CSIDL_SENDTO = 9 '// Send To Folder
'Private Const CSIDL_BITBUCKET = 10 '// Recycle Bin - virtual folder
'Private Const CSIDL_STARTMENU = 11 '// Start Menu
'Private Const CSIDL_DESKTOPFOLDER = 16 '// Desktop folder
'Private Const CSIDL_DRIVES = 17 '// My Computer - virtual folder
'Private Const CSIDL_NETWORK = 18 '// Network Neighbourhood - virtual folder
'Private Const CSIDL_NETHOOD = 19 '// NetHood Folder
'Private Const CSIDL_FONTS = 20 '// Fonts folder
'Private Const CSIDL_SHELLNEW = 21 '// ShellNew folder
Private Const MAX_PATH As Integer = 260
Private Type SPITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As SPITEMID
End Type
Private Declare Function SHGetSpecialFolderLocation Lib "Shell32.dll" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Function GetSpecialFolderPath(CSIDL As Long) As String
Dim sPath As String
Dim IDL As ITEMIDLIST
'
' Retrieve info about system folders such as the "Recent Documents" folder.
' Info is stored in the IDL structure.
'
fGetSpecialFolder = ""
If SHGetSpecialFolderLocation(Form1.hwnd, CSIDL, IDL) = 0 Then
'
' Get the path from the ID list, and return the folder.
'
sPath = Space$(MAX_PATH)
If SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) Then
GetSpecialFolderPath = Left$(sPath, InStr(sPath, vbNullChar) - 1) & "\"
End If
End If
End Function
Private Sub Command1_Click()
Dim strLocation As String
strLocation = GetSpecialFolderPath(CSIDL_DOCUMENTS)
MsgBox strLocation
End Sub
-
Oct 14th, 2011, 06:47 AM
#4
Re: Folder not found
 Originally Posted by Nightwalker83
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.
 Originally Posted by Nightwalker83
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)
-
Oct 14th, 2011, 06:49 AM
#5
Re: Folder not found
 Originally Posted by Hack
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)
-
Oct 14th, 2011, 06:50 AM
#6
Re: Folder not found
 Originally Posted by krtxmrtz
@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)
-
Oct 14th, 2011, 02:18 PM
#7
Re: Folder not found
 Originally Posted by krtxmrtz
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|