一、判斷文件或文件夾是否存在Function FileFolderExists(strFullPath As String) As BooleanOn Error GoTo EarlyExitIf Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = TrueEarlyExit:On Error GoTo 0End Function可判斷文件或文件夾是否存在。假如D盤存在1.txt(文件)、新建文件夾(文件夾),則:msgbox FileFolderExists('D:\1.txt') 'truemsgbox FileFolderExists('D:\1.txt\') 'falsemsgbox FileFolderExists('D:\新建文件夾') 'truemsgbox FileFolderExists('D:\test') 'false二、判斷文件夾是否存在引用于https://www.cnblogs.com/xwdreamer/p/3509701.htmlFunction FileFolderExists(strFullPath As String) As BooleanDim fsoSet fso = CreateObject('Scripting.FileSystemObject')If fso.folderExists(strFullPath) Then FileFolderExists = TrueSet fso = NothingEnd Function
聯(lián)系客服