第1个回答 2014-12-20
Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
'-----------------------判断文件与文件夹是否存在函数
Public Function FiFoExists(ByVal FileName As String) As Boolean
If FileName <> "" Then FiFoExists = CBool(PathFileExists(FileName))
End Function
'-----------------------判断文件是否存在函数
Public Function FileExists(ByVal FileName As String) As Boolean
If FileName <> "" Then TempBol = CBool(PathFileExists(FileName))
If TempBol Then FileExists = Not FolderOrFile(FileName)
End Function
'-----------------------判断文件夹是否存在函数
Public Function FolderExists(ByVal FileName As String) As Boolean
If FileName <> "" Then TempBol = CBool(PathFileExists(FileName))
If TempBol Then FolderExists = FolderOrFile(FileName)
End Function
'-----------------------判断一个路径是文件夹还是文件
Public Function FolderOrFile(strPath As String) As Boolean
If GetAttr(strPath) And vbDirectory Then FolderOrFile = True Else FolderOrFile = False
End Function本回答被提问者和网友采纳