Pastetool - FileExists2

URL: , Paste another

'   for     FileExists()
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName$, lpFindFileData As WIN32_FIND_DATA) As Long
' Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile&, lpFindFileData As WIN32_FIND_DATA) As Long
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile&) As Long
Private Const SW_SHOWNORMAL As Long = 1
Private Const _
        INVALID_HANDLE_VALUE As Long = -1, _
        MAX_PATH As Long = 260&

Private Type FILETIME
  dwLowDateTime As Long
  dwHighDateTime As Long
End Type

Private Type WIN32_FIND_DATA
    dwFileAttributes As Long
    ftCreationTime As FILETIME
    ftLastAccessTime As FILETIME
    ftLastWriteTime As FILETIME
    nFileSizeHigh As Long
    nFileSizeLow As Long
    dwReserved0 As Long
    dwReserved1 As Long
    cFileName As String * MAX_PATH
    cAlternate As String * 14
End Type
'   for     FileExists()


Function FileExists(FileName As String) As Boolean

    Dim WFD As WIN32_FIND_DATA
     
    Dim hSearch As Long ' Search Handle
    hSearch = FindFirstFile(FileName, WFD)
    If hSearch <> INVALID_HANDLE_VALUE Then
        FileExists = True
    End If
    FindClose hSearch
End Function

Download code

This visual basic code was pasted on September 8, 2009




Protected with advance Anti-SPAM techniques :)
Coded and designed by Fedmich
Follow us on Twitter