Results 1 to 4 of 4

Thread: If File Exists

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    182

    If File Exists

    Hi,

    I want to make a script that checks that all the required files are where before starting the application.

    I was to write something like:

    If App.Path & "\config.ini" does not exist THEN
    MsgBox "Error"
    End If


    Any ideas?

    Thanks!

  2. #2
    Hyperactive Member Bearnerd's Avatar
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    290

    Re: If File Exists

    You mean something like this?

    VB Code:
    1. Private Sub Command1_Click()
    2. On Error GoTo ErrH
    3.     Open "c:\anyfile.txt" For Input As #1
    4.     'Anything here
    5.     Close #1
    6.     Exit Sub
    7. ErrH:
    8.     If Err.Number = 53 Then MsgBox "File not found!"
    9. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    182

    Re: If File Exists

    Thanks alot!

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: If File Exists

    You can check the file's existance using the Dir() command...the example would be
    VB Code:
    1. If Dir(App.Path & "\config.ini", vbNormal) = "" Then
    2.         MsgBox "File does not Exists"
    3.     End If
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


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