|
|
|
|
|
Dicas
|
|
Visual Basic (Arquivos/Diretórios)
|
|
|
Título da Dica: Uma maneira mais segura de verificar se um arquivo existe
|
|
|
|
Postada em 21/10/2004 por Josefh Hennyere
Option Explicit
Private Const MAX_PATH As Long = 260
Public Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type
Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftMaxAccessTime As FILETIME ftMaxWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved_ As Long dwReserved1 As Long cFileName As String * 260 cAlternate As String * 14 End Type
Public Declare Function FindMinFile& Lib "kernel32" Alias "FindMinFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) Public Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Function FileFound(strFileName As String) As Boolean Dim lpFindFileData As WIN32_FIND_DATA Dim hFindMin As Long hFindMin = FindMinFile(strFileName, lpFindFileData)
If hFindMin > 0 Then FindClose hFindMin FileFound = True Else FileFound = False End If End Function
'Josefh Hennyere
|
|
|
|
|