• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Detect File

Just wondering if i can get vb to somehow detect a file "reg.dat" exsits
and if it does make vb set a string to whatever
0
gthgb
Asked:
gthgb
1 Solution
 
headerCommented:
Here is a function to tell you if a file exists. It returns true if it exists and false if it doesn't.

Public Function FileExists(ByVal sFile As String) As Boolean
   On Error GoTo Not_ExistFile
   '
   Dim szResults As String
   '
   szResults = Dir$(sFile)
   If szResults = "" Then
      FileExists = False
   Else
      FileExists = True
   End If
   '
   Exit Function
   '
Not_ExistFile:
   FileExists = False
   Exit Function
   '
End Function



To use this:

If FileExists("C:\Windows\Reg.dat") Then
    ...
End if
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now