给定文件的完整路径,如何判断文件夹是否存在?
例如
str="D:\Program Files\abc\a.exe"
如何判断D:\Program Files\abc这个文件夹是否存在??
例如
str="D:\Program Files\abc\a.exe"
如何判断D:\Program Files\abc这个文件夹是否存在??
If dir(str,vbDirectory)<>" Then
MsgBox "存在"
Else
MsgBox "不存在"
End If
更正:
If dir("D:\Program Files\abc",vbDirectory)<>" Then
MsgBox "存在"
Else
MsgBox "不存在"
End If
也可以使用文件操作的方法:
先引用:"Microsfot Scripting Runtime"
Dim fso As New FileSystemObject
Private Sub Command1_Click()
If fso.FolderExists(Pathname) = True Then
MsgBox "存在!"
End If
End Sub