
Can someone tell me how I can check for a file at a specified drive address
Mark-
As I said, my routine could use some
improvement, but it works for me in the place
where I needed it. For example, it returns true
for directories- doesn't really bother me, though.
There is a difference in the two routines, though.
Paste this code into a form with a Button on it and
run the proggy.
Joe
_____________snip__________________________
Option Explicit
Private Sub Command1_Click()
Dim bRetVal As Boolean
Dim bRetVal1 As Boolean
bRetVal = FileExistsMark("c:\io.sys")
bRetVal1 = FileExistsJoe("c:\io.sys")
Debug.Print "FileExistsMark " & bRetVal
Debug.Print "FileExistsJoe " & bRetVal1
End Sub
Public Function FileExistsMark(szFileName As String) As Boolean
If Dir(szFileName) <> "" Then FileExistsMark = True
End Function
Public Function FileExistsJoe(ByVal szFileName As String) As Boolean
Dim AttrRet%
On Error Resume Next
AttrRet = GetAttr(szFileName)
If Err.Number Then
Err.Clear
FileExistsJoe = False
Else
FileExistsJoe = True
End If
End Function
________snip___________________________________
--
***********************************************************
Microsoft Developer MVP- Visual Basic
"The unity of freedom has never relied on
uniformity of opinion." (John F. Kennedy)
**********************************************************
PS- Please reply to the newsgroup- except in the
case of flames, insults, etc. (Don't bother.)
Quote:
> Forgive me for my simplistic mindset but wouldn't the Dir() function work
> just a bit better?
> Public Function FileExists(szFileName as String) As Boolean
> If Dir(szFileName) <> "" Then FileExists = True
> End Sub
> Mark Bappe
> PanAmSat Corp
> >DP-
> > This routine could be better, but it
> >works for me.
> > Joe
> >__________snip_________________________
> >Public Function FileExists(ByVal szFileName As String) As Boolean
> > Dim AttrRet%
> > On Error Resume Next
> > AttrRet = GetAttr(szFileName)
> > If Err.Number Then
> > Err.Clear
> > FileExists = False
> > Else
> > FileExists = True
> > End If
> >End Function