判断文件夹是否存在

解决方案 »

  1.   

    可以用两个办法
    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
      

  2.   

    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
      

  3.   

    你那个麻烦
    看我的if dir("c:\xxx")<>" " then
    if getattr("c:\xxx")=vbDirectory then
    msgbox "文件夹xxx 存在"
    else
    msgbox "xxx存在但是个文件"
    end if
    end if
      

  4.   

    不行
    还是不够帅
    我写个帅的
    if dir("c:\xxx")<>" " then
    d=Iif()getattr("c:\xxx")=vbDirectory),msgbox "文件夹xxx 存在",msgbox "文件夹xxx 存在")
    end if
    这个够帅了吧
      

  5.   

    tt=Iif (Dir("c:\xxx") = Nul ,(d = IIf(GetAttr("c:\xxx") = vbDirectory, s = MsgBox("文件夹xxx 存在"), r = MsgBox("文件夹xxx 不存在"))),MsgBox "没有")
    恩恩
    一行完成
      

  6.   

    if dir("c:\xxx")<>" " then
    d=Iif()getattr("c:\xxx")=vbDirectory),msgbox "文件夹xxx 存在",msgbox "文件夹xxx 存在")
    end if
    你是不是写错了啊
      

  7.   

    if dir("c:\xxx")<>"" then d=IIf(getattr("c:\xxx")=vbDirectory,msgbox "文件夹xxx 存在",msgbox "文件夹xxx 存在")这样岂不更帅?! 哈哈
      

  8.   

    aspower_(我是菜鸟!不象某些bb不懂装懂!还装清高!) 
    你给的都用不了
      

  9.   

    aspower_(我是菜鸟!不象某些bb不懂装懂!还装清高!) 
    你给的 有文件就能判断出来,没有这个文件就出错
      

  10.   

    if dir("c:\xxx")<>" " then
    if getattr("c:\xxx")=vbDirectory then
    msgbox "文件夹xxx 存在"
    else
    msgbox "xxx存在但是个文件"
    end if
    end if用这个吧 我那是写着玩
    哈哈