Results 1 to 3 of 3

Thread: Network Folder Exists?

  1. #1

    Thread Starter
    Addicted Member overhill's Avatar
    Join Date
    Mar 2000
    Location
    KS, United States
    Posts
    181

    Network Folder Exists?

    I have a program that sometimes needs to check for the existance of certain folders on network machines. When a computer is fresh from a reboot and no network browsing has been done, I am unable to confirm the existance of the folder using the FileSystemObject (even though I know it exists). If I replace the computer name with its network IP I am then told it exists. If before I do any of this, I browse to this network folder, I get the results like I want them and the FolderExists comes back True whether I use the computer name or IP.

    My question then is, what measures must I take in order to use the computer name from the very start. Can I call some method that will informs Windows to really check to see if this network folder exists?

    \\supertramp\folder_test = returns False
    \\192.168.0.1\folder_test = returns True

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Try the GetFileAttributes() API, i.e.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
    4. Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
    5.  
    6. Private Sub Command1_Click()
    7.     Dim lAttrib As Long
    8.    
    9.     Caption = "Checking..."
    10.    
    11.     lAttrib = GetFileAttributes(Text1.Text)
    12.    
    13.     Caption = _
    14.         IIf(lAttrib <> -1 And _
    15.             (lAttrib And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY, _
    16.             "Exists", "Doesn't Exist")
    17. End Sub

  3. #3

    Thread Starter
    Addicted Member overhill's Avatar
    Join Date
    Mar 2000
    Location
    KS, United States
    Posts
    181
    Thanks for the reply Aaron, but that didn't work either. I just made a little program that allows me to check if a certain folder exists using three different methods and none of them will show a folder using the computer name after a reboot. But if I replace the computer name with the IP and test just one of them, then immediately afterwards, all three methods will work.

    It seems to be a Windows networking hassle. Perhaps if I tried creating (or reading) from a file in that folder first things would begin to work. I'll try that when I have the time to reboot again!

    Any other ideas would be greatly appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width