|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with DIR function.....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 Thanks, John John Morley wrote:
Show quoteHide quote > A customer reported that he encounters an Error #53 (file not found) when Your code is almost identical to the example given in the MSDN library for> 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 > 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 Mueller [MVP] wrote:
Show quoteHide quote > John Morley wrote: Richard,> > >>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. > 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
Show quote
Hide quote
"John Morley" <jmorley@nospamanalysistech.com> wrote in message I realized after I responded that you must have appended the trailing news:eBuskRd%23JHA.1492@TK2MSFTNGP03.phx.gbl... > 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 > 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. If you don't want to guess you can just place a Debug.Print or somesort of
logging in the routine to see exactly where and on what filename/folder the issue occurs. It might have something to do with the Do While or Do Until loop. One checks before and the other checks after. I forget which. -- Show quoteHide quoteRandem Systems Your Installation Specialist The Top Inno Setup Script Generator http://www.randem.com/innoscript.html Disk Read Error Press Ctl+Alt+Del to Restart http://www.randem.com/discus/messages/9402/9406.html?1236319938 "John Morley" <jmorley@nospamanalysistech.com> wrote in message news:OQEkyra%23JHA.4900@TK2MSFTNGP02.phx.gbl... > Hi All, > > 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 > > Thanks, > > John |
|||||||||||||||||||||||