Sign-up....

给定文件的完整路径,如何判断文件夹是否存在?

例如

str="D:\Program Files\abc\a.exe"

如何判断D:\Program Files\abc这个文件夹是否存在??

[75 byte] By [msdn] at [2007-8-14 12:06:01]
# 1 Re: 给定文件的完整路径,如何判断文件夹是否存在?

If dir(str,vbDirectory)<>" Then

MsgBox "存在"

Else

MsgBox "不存在"

End If

XunBaian at 2005-4-6 17:13:31 >
# 2 Re: 给定文件的完整路径,如何判断文件夹是否存在?

更正:

If dir("D:\Program Files\abc",vbDirectory)<>" Then

MsgBox "存在"

Else

MsgBox "不存在"

End If

XunBaian at 2005-4-6 17:13:58 >
# 3 Re: 给定文件的完整路径,如何判断文件夹是否存在?

也可以使用文件操作的方法:

先引用:"Microsfot Scripting Runtime"

Dim fso As New FileSystemObject

Private Sub Command1_Click()

If fso.FolderExists(Pathname) = True Then

MsgBox "存在!"

End If

End Sub

junki at 2005-4-6 18:06:15 >

VB

All Classified