Results 1 to 4 of 4

Thread: How can I check if a file exist?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    3
    Hi!

    A textfile is created with a batchfile.
    I have to analyze this textfile, when it's there.

    Now how can I check if the textfile is already there?
    How can i delete it fast after checking?
    And biggest question: How can I tell the programm to WAIT until there is a file to check?

    I thank you very much for your time and help
    Daemon72

    PS: Is there any module out there, which can do all important file operations like deleting, moving, renaming, lookin if exist...?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    I use a function like this:

    Code:
    Public Function Exists(ByVal fn As String) As Boolean
        On Error GoTo NO_FILE
            
        Exists = (FileLen(fn) > 0)
        
        Exit Function
        
    NO_FILE:
        Exists = False
    End Function
    -Shickadance

  3. #3
    Guest
    Code:
     if Dir(path) <> "" then msgbox "File does exist"

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ..File system object has many features

    'does file exist using fso

    Dim sFile$

    sFile = "Name And Path Of Your File"

    Dim fs As Object
    Set fs = CreateObject("Scripting.FileSystemObject")

    StartOver:

    If fs.fileexists(sFile$) = True Then
    MsgBox "File Exists...Your code here!"
    Else
    MsgBox "Does Not Exist...Your code here!"
    'perhaps you could loop it here till the file
    does exist ie..goto StartOver:
    End If
    Set fs = Nothing


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width