Henry,

There are a number of bugs with Dir that could be due to the operating
system, your network configuration or just Visual Basic having trouble with
certain files.  I don't know that any of these apply to your specific
situation, but here are a few at a very, very quick glance to get you
thinking about the problem in a general sense.

For example, if you are running the following code on NT 4.0,

If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory

then the Visual Basic GetAttr() function fails on Pagefile.sys, which is the
Windows NT virtual memory paging file.  The Pagefile.sys file on a Windows
NT 4.0 computer is being read as a folder when it is encountered, but when
the file is checked by the GetAttr function it fails the value check.  To
work around this error message, ignore the Pagefile.sys file by adding a
reference to it in the first If statement in the macro example.  The
following code is a copy of the example with the reference added. 

   'Display the names in C:\ that represent directories.
   MyPath = "c:\"   'Set the path.
   MyName = Dir(MyPath, vbDirectory)   ' Retrieve the first entry.
   
   Do While MyName <> ""   ' Start the loop.

      'Ignore the current directory and the encompassing directory.
      If MyName<>"." And MyName<>".." And MyName<>"Pagefile.sys"   Then

         'Use bitwise comparison to make sure MyName is a directory.
         If(GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then

            'Display entry only if it represents a directory.
            Debug.Print MyName
         End If
      End If 
   MyName = Dir 
   'Get next entry.  
   Loop 


If you use the DIR command with a UNC path to an already mapped Windows 95
share from a Windows NT 3.51 Service Pack 3 computer, the following error
message appears: 
Directory of \\<Windows 95 Computer>\<Share Name> File Not Found. 
Microsoft has confirmed this to be a problem in Windows NT version 3.51
Service Pack 3. This problem was corrected in the latest Windows NT 3.51
U.S. Service Pack.


When you connect to a NetWare server using the Windows NT Gateway Services
for NetWare (GSNW), if you attempt to use the DIR command in a directory on
the NetWare server, you may receive the following error message: 
File not found 
If you make a direct connection to the NetWare server (without using GSNW),
this problem does not occur.


MSDN has a lot of articles on bugs with Dir, but you may have to look at the
specifics of your environment to get to the root of the problem.  I
encourage you to act on your curiosity and explore the question; I've done
some of my best learning that way.

Dennis Sanderson
Programmer / Analyst
Brooks Health System
MCSD, MCSE, MCDBA


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 10:36 AM
To: [EMAIL PROTECTED]
Subject: RE: [Talk] Accessing files on an x: drive


Yeah, I tried that, too.  Using the full path still returns an attribute
value of 2064.

Regarding David Higginson's reply, I saw that in the Help files, too.  The
only attribute that my folder has on is compress.  Now, that's not one of
the named constants in the help file, and I can't get those to sum at 2064.
There may perhaps be another constant value for compressed directories that
isn't listed here, that would make it total 2064.

I'm just going to remove the check on the directory, since I know what it
is and I know it's a directory.  I'm really just curious at this point.

Henry Taylor
Applications Analyst
Lutheran Health Network
Ph. (260) 425-3914


 

                    "Ron Meyer"

                    <[EMAIL PROTECTED]>         To:
<[EMAIL PROTECTED]>                                     
                    Sent by:                     cc:

                    [EMAIL PROTECTED]       Subject:     RE: [Talk]
Accessing files on an x: drive                   
                    TATION.COM

 

 

                    07/09/03 09:15 AM

                    Please respond to Talk

 

 





Try using the full path to the network drive
(\\myserver\bws\selfpay\data)

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 7:10 AM
To: [EMAIL PROTECTED]
Subject: [Talk] Accessing files on an x: drive


     I'm just wondering, in order to try and rule out possibilities in
my
troubleshooting, whether I should experience any problems in accessing
files on a mapped drive using BWS and VBA.  I wouldn't think so, but I
need
to be sure.
     When I set a data path constant to 'x:\bws\selfpay\data', I get an
invalid directory error.  I have a function that loops through files in
a
directory and returns the file names in an array; this allows me to
import
multiple files at once.  I've copied the function below.  Based on my
debugging, I believe the error is generated because the GetAttr(DataDir)
does not equal vbDirectory.  What I don't know is why.  I don't know if
there's something inherent in a directory on a mapped drive that will
change the number of the attribute, or if something else is going on.
Anyone have any ideas?

Function GetAllFilesInDir(ByVal DataDir As String) As Variant
    ' Loop through the directory specified in strDirPath and save each
    ' file name in an array, then return that array to the calling
    ' procedure.
    ' Return False if strDirPath is not a valid directory.
    Dim strTempName As String
    Dim varFiles() As Variant
    Dim lngFileCount As Long

    On Error GoTo GetAllFiles_Err

    ' Make sure that strDirPath ends with a "\" character.
    If right$(DataDir, 1) <> "\" Then
        DataDir = DataDir & "\"
    End If

    ' Make sure strDirPath is a directory.
    If GetAttr(DataDir) = vbDirectory Then
        strTempName = Dir(DataDir, vbDirectory)
        Do Until Len(strTempName) = 0
            ' Exclude ".", "..".
            If (strTempName <> ".") And (strTempName <> "..") And
(right(strTempName, 3) <> "rnd") Then
                ' Make sure we do not have a sub-directory name.
                If (GetAttr(DataDir & strTempName) _
                    And vbDirectory) <> vbDirectory Then
                    ' Increase the size of the array
                    ' to accommodate the found filename
                    ' and add the filename to the array.
                    ReDim Preserve varFiles(lngFileCount)
                    varFiles(lngFileCount) = strTempName
                    lngFileCount = lngFileCount + 1
                End If
            End If
            ' Use the Dir function to find the next filename.
            strTempName = Dir()
        Loop
        ' Return the array of found files.
        GetAllFilesInDir = varFiles
    End If
GetAllFiles_End:
    Exit Function
GetAllFiles_Err:
    GetAllFilesInDir = False
    Resume GetAllFiles_End
End Function

Henry Taylor
Applications Analyst
Lutheran Health Network
Ph. (260) 425-3914


The information is intended only for the use of the individual
or entity named above.  The unauthorized recipient of this
information is prohibited from disclosing the information to another
person.
If received in error please notify the sender immediately, destroy the
information that was sent in error, and keep any information you viewed
confidential.  Any disclosure, copying, distribution or action taken in
reliance on the contents of these documents is strictly prohibited.




Reply via email to