Re: Problem with DIR function.....

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance





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


.



Relevant Pages

  • Re: Problem with DIR function.....
    ... 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. ... ' Use bitwise comparison to make sure FFile is a directory. ... DataFolderPath has a trailing backslash. ...
    (microsoft.public.vb.general.discussion)
  • Re: Problem with DIR function.....
    ... 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 ... customer to "Zip" his data directory and send it to me, ... ' Use bitwise comparison to make sure FFile is a directory. ...
    (microsoft.public.vb.general.discussion)
  • Re: Problem with DIR function.....
    ... It might have something to do with the Do While or Do Until loop. ... Combobox with the names of all sub-directories inside a main data ... customer to "Zip" his data directory and send it to me, ... ' Use bitwise comparison to make sure FFile is a directory. ...
    (microsoft.public.vb.general.discussion)
  • Re: Scanner class and last line in a file
    ... I can't repro the problem - help me understand what I'm missing. ... the following test class: ... And input file with no trailing newline created by: ... Then the second part of the for loop checks ...
    (comp.lang.java)
  • Re: A graph application
    ... Basically you are starting at the root directory, ... The fun comes when sub-directories are allowed to contain references to ... If you don't find a loop, ... is not a link to a parent, and you can continue as normal. ...
    (comp.lang.c)