Results 1 to 4 of 4

Thread: [RESOLVED] Check for a file in app directory

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    Resolved [RESOLVED] Check for a file in app directory

    Hi guys,

    Does anyone know how to make it so when a user presses a command button it checks to see if there is a file for example "file.exe" in the same folder as the application and if the file is in their (file.exe) then it will load form 2. But if the file aint fount it gives them a msgbox "File.exe was not found please download file.exe before continuing"


    thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Check for a file in app directory

    Here is an example. Modify it to suit your individual needs
    vb Code:
    1. If Dir$("c:\autoexec.bat") <> vbNullString Then
    2.    MsgBox "file exists"
    3. Else
    4.    MsgBox "file doesn't exist"
    5. End If
    6. End Sub

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Check for a file in app directory

    vb Code:
    1. Sub Sample()
    2.     Dim FlName As String
    3.    
    4.     '~~> Replace with Relevant File name
    5.     FlName = Dir(App.Path & "MyFile.Exe")
    6.    
    7.     If (FlName) <> "" Then
    8.         '~~> File is there
    9.         Form2.Load
    10.     Else
    11.         '~~> File is not there
    12.         MsgBox "File Doesn't Exist"
    13.     End If
    14. End Sub

    Edit: Ah! Hack beat me to it...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    Re: Check for a file in app directory

    Awesome!!

    Thanks guys, Really appreciate it!

    All the best,

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