Re: Problem with DIR function.....
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 30 Jun 2009 19:03:16 -0500
"John Morley" <jmorley@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:eBuskRd%23JHA.1492@xxxxxxxxxxxxxxxxxxxxxxx
Richard Mueller [MVP] wrote:
John Morley wrote:
A customer reported that he encounters an Error #53 (file not found) when
he runs my application. Upon investigation, the error is occurring in a
subroutine that uses a Do While loop and the DIR function to populate a
Combobox with the names of all sub-directories inside a main data
directory. I've added some diagnostics, and the code loops 5 or 6 times
before the error is encountered. I suspect that some attribute of the
"problem" directory is causing the problem? Interestingly, I asked the
customer to "Zip" his data directory and send it to me, and the
compressed archive he sent does not contain all the sub-directories
inside the main data directory. It's as if whatever is causing the Error
#53 problem is also not allowing the sub-directories to be archived?
Any thoughts on the problem, or suggestions on a better method to do
this? The code below is at least 10 years old, and has never failed
previously!
ComboList.Clear
FFile = Dir(DataFolderPath, vbDirectory)
Do While FFile <> ""
' Ignore the current directory and the encompassing directory.
If FFile <> "." And FFile <> ".." Then
' Use bitwise comparison to make sure FFile is a directory.
If (GetAttr(DataFolderPath & FFile) And vbDirectory) =
vbDirectory Then
ComboList.AddItem FFile, i
i = i + 1
End If
End If
FFile = Dir 'get next entry
Loop
Your code is almost identical to the example given in the MSDN library
for
the Dir function. I get error 53 if the path is a folder and I do not
include the trailing "\". I tested on Vista. Perhaps make sure
DataFolderPath has a trailing backslash.
Richard,
Ha, now I know where the code came from originally :-)!
Here is how I set DataFolderPath: DataFolderPath = gProgDir + "Data\"
So, you can see I do include the trailing "\". It's a strange problem, and
it appears unique to this one particular installation. I know the
sub-directory (by name) that causes the problem, so the end-user is
checking to see if that sub-directory has some sort of weird properties.
Failing that, I'm kind of stuck......
Thanks,
John
I realized after I responded that you must have appended the trailing
backslash, since the code looped a few times before raising the error. I
tried a few things, like crazy folder names, but could not duplicate the
error in the loop. If you know the name, and it seems normal, it must be
something else.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
.
- References:
- Re: Problem with DIR function.....
- From: John Morley
- Re: Problem with DIR function.....
- Prev by Date: Re: Problem with DIR function.....
- Next by Date: Re: Type comparison
- Previous by thread: Re: Problem with DIR function.....
- Next by thread: Re: Problem with DIR function.....
- Index(es):
Relevant Pages
|