如题所述
'å¤ææ件
Public Function FileExists(ByVal File As String) As Boolean
On Error Resume Next
If (GetAttr(File) And vbDirectory) = False Then FileExists = True
If err Then FileExists = False: err.Clear
End Function
'å¤æç®å½
Function FolderExists(ByVal Folder As String) As Boolean
On Error Resume Next
If GetAttr(Folder) And vbDirectory Then FolderExists = True
If err Then FolderExists = False: err.Clear
End Function
Public Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal DirPath As String) As Long
ç¨æ³ï¼
MakeSureDirectoryPathExists "c:/this/is/a/test/directory/"
Public Function FileExists(ByVal File As String) As Boolean
On Error Resume Next
If (GetAttr(File) And vbDirectory) = False Then FileExists = True
If err Then FileExists = False: err.Clear
End Function
'å¤æç®å½
Function FolderExists(ByVal Folder As String) As Boolean
On Error Resume Next
If GetAttr(Folder) And vbDirectory Then FolderExists = True
If err Then FolderExists = False: err.Clear
End Function
'å建å¤å±ç®å½
Public Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal DirPath As String) As Long
ç¨æ³ï¼
MakeSureDirectoryPathExists "c:/this/is/a/test/directory/"
温馨提示:答案为网友推荐,仅供参考
第1个回答 2014-04-23
用dir函数,更喜欢用fso
第2个回答 2014-04-23
API函数:FileExist,可能记错了
第3个回答 2014-04-23
dir(路径)