Dir function has bug? 
Author Message
 Dir function has bug?

I am trying to list all the files in a specified directory.
Dir function does work...
Does anybody know why?

In the following code, the first call to Dir returns empty string rather
than first file name;

    strFile = Dir(strDir)   ' Retrieve the first entry.

    Do While strFile <> ""   ' Start the loop.
        ' Ignore the current directory and the encompassing directory.
        If strFile <> "." And strFile <> ".." Then
            strPath = strDir + strFile
            If (GetAttr(strPath) And vbDirectory) = vbDirectory Then
                Debug.Print "Directory:" + strPath
                'GetFiles (strPath)
            Else
                Debug.Print strPath
            End If

        End If

        strFile = Dir()    ' Get next entry.
    Loop



Sun, 08 Dec 2002 03:00:00 GMT  
 Dir function has bug?
I have an ASP script that can do this. It should be easily modifiable to
VBScript.

Have a look on http://www.sourcecodecorner.com in the articles section.

Dave.
~~
All I ask is a chance to prove that money can't make me happy.

Tips, tricks and articles for programmers of all languages on
http://www.sourcecodecorner.com

Advertise your car for free on http://www.drivingseat.com



Quote:
> I am trying to list all the files in a specified directory.
> Dir function does work...
> Does anybody know why?

> In the following code, the first call to Dir returns empty string rather
> than first file name;

>     strFile = Dir(strDir)   ' Retrieve the first entry.

>     Do While strFile <> ""   ' Start the loop.
>         ' Ignore the current directory and the encompassing directory.
>         If strFile <> "." And strFile <> ".." Then
>             strPath = strDir + strFile
>             If (GetAttr(strPath) And vbDirectory) = vbDirectory Then
>                 Debug.Print "Directory:" + strPath
>                 'GetFiles (strPath)
>             Else
>                 Debug.Print strPath
>             End If

>         End If

>         strFile = Dir()    ' Get next entry.
>     Loop



Sun, 08 Dec 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Freak VB5.0 bug with UNC Names and DIR$ function

2. Watch out: Potential bug in Dir function!

3. DIR function bug?

4. Dir$ function and Dir listbox gives different results

5. Dir function not functioning correctly...

6. Having trouble with that WSHNetwork.UserName logon script bug

7. bug in DIR command

8. Dir$ Problem/bug??

9. Dir$ problem/bug

10. a dir() bug?!?!

11. bug in DIR command

12. DIR bug report....

 

 
Powered by phpBB® Forum Software