有个object.FileExists(filespec)方法。
CreateTextFile 创建文本文件。

解决方案 »

  1.   

    '引用microsoft scripting runtime
    Private Sub Form_Load()
        Dim f As New FileSystemObject
        If Not f.FileExists("c:\try.txt") Then
            f.CreateTextFile ("c:\try.txt")
        End If
    End Sub
      

  2.   

    使用FileExists判断文件是否存在,比如
    创建新文件可以使用FileSystemObject对象,首先添加
    Microsoft Scripting Runtime的引用,再再程序中声明一个变量
    比如MyFSO.CreateTextFile "C:\MyText.txt", True
    就可以了
    Dim MyFSO As FileSystemObjectif FileExists("C:\Mytext.txt")  THen
        
        '
        MyFSO.OpenTextFile "C:\Mytext.txt"else    MyFSO.CreateTextFile "C:\MyText.txt", Trueend if
      

  3.   

    用什么文件系统啊。没事找事做。好好的程序又加上个dll。难道msvbvm60.dll你们还闲不够大吗?
    直接用vb本身提供的函数就好了啊。
    1:判断文件是否存在。
    Public Function OnDisk(Filename As String) As Boolean
    If Dir(Filename, vbHidden) = "" Then
    OnDisk = False
    Else
    OnDisk = True
    End If
    End Function使用: x=ondisk(文件名)
    如果x=true 则文件存在 反之不存在。2:创建文件
    dim fno as integer
    fno=freefile
    open 文件名 for output as #fno
    close fno
    这样文件就创建好了啊
    !!!!!!!!!!
    上面所有的文件名都是代路径和后缀名的。
      

  4.   

    Public Function FileExists%(FileName$)Dim f%   ' Trap any errors that may occur
       On Error Resume Next   ' Get a free file handle to avoid using a file handle already in use
       f% = FreeFile
       ' Open the file for reading
       Open FileName$ For Input As #f%
       ' Close it
       Close #f%
       ' If there was an error, Err will be <> 0. In that case, we return False
       FileExists% = Not (Err <> 0)End Function