|
-
Mar 9th, 2002, 08:01 PM
#1
Thread Starter
Addicted Member
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
-
Mar 9th, 2002, 08:25 PM
#2
Try the GetFileAttributes() API, i.e.
VB Code:
Option Explicit
Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
Private Sub Command1_Click()
Dim lAttrib As Long
Caption = "Checking..."
lAttrib = GetFileAttributes(Text1.Text)
Caption = _
IIf(lAttrib <> -1 And _
(lAttrib And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY, _
"Exists", "Doesn't Exist")
End Sub
-
Mar 9th, 2002, 09:28 PM
#3
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|