Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the preferred method of determining a file exists.

Status
Not open for further replies.

GAORR

Programmer
Nov 22, 2001
48
CA
I'm looking for the preferred method of determining if a file (data base) exists before running an app. I have seen different methods, such as dir, opening a file, and I suspect there are API's that will accomplish this also.

Any thoughts ?

Thanks
 
I prefer Dir but all methods all are acceptable and I think are just as fast.

' Initialize files
InFileName = txtInputFile.Text
OutFileName = txtOutputFile.Text
Counter = 0
Counter2 = 0

' Verify replacement of output file if it exists
If Dir(OutFileName) <> &quot;&quot; Then
Msg = &quot;Replace contents of &quot; + OutFileName + &quot;?&quot;
If MsgBox(Msg, 4, &quot;Replace File?&quot;) = 6 Then
Kill OutFileName
Else
txtOutputFile.SetFocus
txtOutputFile.SelStart = 0
txtOutputFile.SelLength = Len(txtOutputFile)
Exit Sub
End If
End If
 
You might find the .FileExists method of the FileSystemObject useful
Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top