Results 1 to 2 of 2

Thread: Checking for file existance before proceeding.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Posts
    30

    Question

    In my VB application I come to a point where I have to open up another application, and then use some SendKeys functions in order to get the other application to download a file from the company's mainframe to the local hard drive.

    I need to know how I can get my VB program to wait until the file has been created and the application is finished downloading information before using some more SendKey functions.

    If I'm off by a second and acciendtially use a SendKey function while the download is occuring the download will stop but the file will be created and appear to be complete when it really isnt.

    Please help me,
    Brandr Beekman
    [email protected]

  2. #2
    Guest
    You could always make your program sleep a little longer.
    Check if a file exists:
    Code:
    Public Function fileexists(strfilepathandname As String) As Boolean
        On Error Resume Next
        Dim lngcheck As Long
        If InStr(strfilepathandname$, ".") = 0& Then
            Let fileexists = False
        End If
        Let lngcheck& = Len(Dir$(strfilepathandname$))
        If lngcheck& = 0& Then
            Let fileexists = False
            Exit Function
        Else
            Let fileexists = True
        End If
        Exit Function
    End Function
    
    If fileexists("C:\myfile.txt") Then
    'code
    Else
    Exit Sub
    End If
    Or if you know the application's caption:
    Code:
    AppActivate "Program's Caption"
    Sendkeys "whatever"

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