|
-
Dec 7th, 2001, 01:52 PM
#1
Thread Starter
Frenzied Member
File Exists (On NetWork)
how do I check to see if a file exists on the other end of a network?
The file is
\\Eduardo\c\WINNT\customerinfo.mdb
and this code doesnt work:
VB Code:
Function FileExists(s As String) As Boolean
If Dir(s) <> "" Then
FileExists = True
Else
FileExists = False
End If
End Function
Last edited by Evan; Dec 7th, 2001 at 01:55 PM.
-
Dec 7th, 2001, 02:13 PM
#2
New Member
Try this version of FileExists instead :
MyCheck = FileExists("\\Eduardo\c\WINNT\customerinfo.mdb")
Private Function FileExists(FullFileName As String) As Boolean
On Error GoTo MakeF
'If file does Not exist, there will be an Error
Open FullFileName For Input As #1
Close #1
'no error, file exists
DoExists = True
Exit Function
MakeF:
'error, file does Not exist
DoExists = False
Exit Function
End Function
-
Dec 7th, 2001, 02:28 PM
#3
Thread Starter
Frenzied Member
-
Dec 7th, 2001, 02:29 PM
#4
Do you need to use the UNC name? I've found it much easier to temporarily map a drive to the server using an unused drive letter, do my check, then disconnect the drive. That way, I can use something like s:\WINNT\customerinfo.mdb
-
Dec 7th, 2001, 02:40 PM
#5
why not use the Dir() function?
VB Code:
MyCheck = FileExists("\\Eduardo\c\WINNT\customerinfo.mdb")
Private Function FileExists(FullFileName As String) As Boolean
If len(Dir(FullFileName,vbNormal)) = 0 Then FileExsist = False Else FileExisit = True
End Function
if that file is LARGE then your app will slow down if the file does exsist. it will have to open it over the network, then just close it.
this just checks the length of the file
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Dec 7th, 2001, 02:42 PM
#6
Thread Starter
Frenzied Member
Originally posted by geoff_xrx
why not use the Dir() function?
VB Code:
MyCheck = FileExists("\\Eduardo\c\WINNT\customerinfo.mdb")
Private Function FileExists(FullFileName As String) As Boolean
If len(Dir(FullFileName,vbNormal)) = 0 Then FileExsist = False Else FileExisit = True
End Function
Thats what I was using. It wont work over the network.
and yes, the other way does slow my program down.
if that file is LARGE then your app will slow down if the file does exsist. it will have to open it over the network, then just close it.
this just checks the length of the file
-
Dec 7th, 2001, 03:07 PM
#7
yo probably dont have the correct path...
I tried it over my network. works fine
but heres the kicker...the mapped drive is not as obvious a path...
mine looked like \\ROC_S1\C\filename.txt
but it was actually a folder
\\ROC_S1\ROC_Share\filename.txt
go into you "entire Network" find eduardo...then look for the folder containing the file
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Dec 7th, 2001, 03:09 PM
#8
Thread Starter
Frenzied Member
Oh... I fixed it. This works!
VB Code:
Private Function FileExists(FullFileName As String) As Boolean
On Error GoTo CheckError
If Len(Dir(FullFileName, vbNormal)) = 0 Then
FileExsist = False
Else
FileExisit = True
End If
Exit Function
CheckError:
FileExists = False
End Function
-
Dec 7th, 2001, 03:11 PM
#9
Thread Starter
Frenzied Member
I know the file exists, but his computer isnt on.
So I guess that drive has to exist.
-
Dec 7th, 2001, 03:16 PM
#10
lol!
that would be very helpful!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Dec 7th, 2001, 03:20 PM
#11
Thread Starter
Frenzied Member
You would think a function called 'FileExists' Could work all the time... guess not...
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
|