可以用两个办法 fso办法 先引用它呀 Microsoft Scripting Control 1.0 dim fs as new filesystemobject if fs.folderexists("c:\T") then msgbox"文件夹已存在!" else fs.createfolder("c:\T") end if dir也可以不过可能出错如果有个和文件名一样的空后缀的名文件就会认为文件夹已经存在了 if dir("文件夹",vbdirectory)=nul then mkdir "文件夹" end if
Private Sub Command1_Click() If Dir("c:\test", vbDirectory + vbSystem + vbReadOnly + vbNormal + vbHidden) = "" Then MsgBox "不存在" Else If GetAttr("c:\test") And vbDirectory Then MsgBox "存在" Else MsgBox "不存在" End If End If End Sub
你那个麻烦 看我的if dir("c:\xxx")<>" " then if getattr("c:\xxx")=vbDirectory then msgbox "文件夹xxx 存在" else msgbox "xxx存在但是个文件" end if end if
不行 还是不够帅 我写个帅的 if dir("c:\xxx")<>" " then d=Iif()getattr("c:\xxx")=vbDirectory),msgbox "文件夹xxx 存在",msgbox "文件夹xxx 存在") end if 这个够帅了吧
tt=Iif (Dir("c:\xxx") = Nul ,(d = IIf(GetAttr("c:\xxx") = vbDirectory, s = MsgBox("文件夹xxx 存在"), r = MsgBox("文件夹xxx 不存在"))),MsgBox "没有") 恩恩 一行完成
if dir("c:\xxx")<>" " then d=Iif()getattr("c:\xxx")=vbDirectory),msgbox "文件夹xxx 存在",msgbox "文件夹xxx 存在") end if 你是不是写错了啊
if dir("c:\xxx")<>"" then d=IIf(getattr("c:\xxx")=vbDirectory,msgbox "文件夹xxx 存在",msgbox "文件夹xxx 存在")这样岂不更帅?! 哈哈
fso办法 先引用它呀
Microsoft Scripting Control 1.0 dim fs as new filesystemobject
if fs.folderexists("c:\T") then
msgbox"文件夹已存在!"
else
fs.createfolder("c:\T")
end if dir也可以不过可能出错如果有个和文件名一样的空后缀的名文件就会认为文件夹已经存在了
if dir("文件夹",vbdirectory)=nul then
mkdir "文件夹"
end if
If Dir("c:\test", vbDirectory + vbSystem + vbReadOnly + vbNormal + vbHidden) = "" Then MsgBox "不存在"
Else
If GetAttr("c:\test") And vbDirectory Then
MsgBox "存在"
Else
MsgBox "不存在"
End If
End If
End Sub
看我的if dir("c:\xxx")<>" " then
if getattr("c:\xxx")=vbDirectory then
msgbox "文件夹xxx 存在"
else
msgbox "xxx存在但是个文件"
end if
end if
还是不够帅
我写个帅的
if dir("c:\xxx")<>" " then
d=Iif()getattr("c:\xxx")=vbDirectory),msgbox "文件夹xxx 存在",msgbox "文件夹xxx 存在")
end if
这个够帅了吧
恩恩
一行完成
d=Iif()getattr("c:\xxx")=vbDirectory),msgbox "文件夹xxx 存在",msgbox "文件夹xxx 存在")
end if
你是不是写错了啊
你给的都用不了
你给的 有文件就能判断出来,没有这个文件就出错
if getattr("c:\xxx")=vbDirectory then
msgbox "文件夹xxx 存在"
else
msgbox "xxx存在但是个文件"
end if
end if用这个吧 我那是写着玩
哈哈