怎样判断某一目录下是否存在文件( 包括任何形式的文件)?为了实现在某一时刻特定的目录下没有任何文件,需要写一个判断语句,检查是否存在某个文件;
不存在则正常,否则就异常。

解决方案 »

  1.   

    Dim strDir as stringif dir(strDir)="" then  '没文件
    else   ‘有文件
    end if
      

  2.   

    if dir("c:\aaa\myfile.txt")<> "" then 
         debug.print "存在"
    else
         debug.print "不存在"
    end if
      

  3.   

    '写错,不好意思if dir(strDir & "\" & strfile)="" then '没文件
    else ‘有文件
    end if