在程序里要对某文件进行拷贝/复制等操作,希望在操作前获取文件状态(是否打开等),本想用api中的GetFileAttributes的但发现不行,不知有什么好办法

解决方案 »

  1.   

    自己写一个函数
    Rem 如果文件未被打开,则返回True,否则返回False
    Public Function FileAllowOpen
    End Public
      

  2.   

    Public Function FileAllowOpen(Filename as string)on error goto e
    open filename for input as #1 len = 1close #1fileallowopen=true
    exit sube:err.clear''为了防止因为文件不存在而造成读写错误
    open filename for random as #1 len = 1
    if lof(1) = 0 then fileallowopen=true else filenameopen=false
    close #1
    End Public