Memeriksa Keberadaan sebuah file

Function FileExists(strPath As String) As Boolean
Dim lngRetVal As Long
On Error Resume Next
lngRetVal = Len(Dir$(strPath, vbReadOnly Or _
vbSystem Or _
vbHidden Or _
vbArchive Or _
vbNormal))

If Err Or lngRetVal = 0 Then
FileExists = False
Else
FileExists = True
End If
End Function

Private Sub Form_Load()
MsgBox FileExists("C:\boot.ini")
End Sub

No comments:

Post a Comment

Related Posts with Thumbnails