如何判断文件是否存在?

来源:百度知道 编辑:UC知道 时间:2024/09/26 14:23:23
输入一个URL,判断该文件或文件夹是否存在
url:比如C:\WIN32API.txt

明白~~~~

看我的答案~~

比他们的简单~~

Private Sub Command1_Click()
MsgBox IIf(Len(Dir(Text1.Text)) <> 0, "存在!", "不存在!")
End Sub

Private Sub Form_Load()
Text1.Text = "c:\bootbak.ini" '这里你可以去掉
End Sub

URL,文件?什么意思?

dir("C:\WIN32API.txt")

文件存在,Dir(文件名)<>""

if Dir("D:\popmenu.htm", vbArchive)="" then
'文件不存在
else
'文件存在
end if

if Dir("D:\ghost", vbDirectory)="" then
'文件夹不存在
else
'文件夹存在
end if