如何判断 用api写 请提供例子 谢谢

解决方案 »

  1.   

    只有一个勉强的办法打开文件读写,如果没有别的程序打开,应该能读写
    '*********************************************************
    '* 名称:FileExists%(filename$)
    '* 功能:此函数用于判断文件是否存在
    '* 用法:FileExists%('文件名称')
    '* 文件不存在返回 0
    '*********************************************************
    Function FileExists%(filename$)
        Dim F%
        
        On Error Resume Next
        
        F% = FreeFile
        Open filename$ For Input As #F%
        Close #F%
        
        FileExists% = Not (Err <> 0)
    End Function
      

  2.   

    你的程序我帮你更改了一下,
    你自己看看吧!
    运行以后
    FileExists=1表示打开成功!
    FileExists=0表示打开不成功!
    Function FileExists%(filename$)
       Dim F%
        
        On Error goto Err:
        
        F% = FreeFile
        Open filename$ For Input As #F%
        Close #F%
        
        FileExists=1
        exit sub
    Err:
    FileExists=0
    End Function