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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can you tell if a disk file exists 1

Status
Not open for further replies.

erosenbaum

Programmer
Jul 28, 1999
1
US
Without opening a file and checking its LOF, or setting an ON ERROR and opening a file, how can I tell if a disk file exists?<br>
<br>
-Edward
 
Dim LookFile as String<br>
LookFile = ""<br>
LookFile = Dir("c:\myfile.dat")<br>
If LookFile = "" then<br>
File does not exist<br>
End-If<br>
<br>
Also check out the help for funtion DIR
 
'Insert the following code to your form:<br>
<br>
Private Sub Form_Load()<br>
'Replace the 'c:\autoexec.bat' with then name of the file (with his path) that<br>
'you want to check his existence<br>
If Dir$(&quot;c:\autoexec.bat&quot;) &lt;&gt; &quot;&quot; Then <br>
MsgBox (&quot;The file exist&quot;)<br>
Else<br>
MsgBox (&quot;The file does not exist&quot;)<br>
End If<br>
End Sub<br>
<br>
<p>Eric De Decker<br><a href=mailto:vbg.be@vbgroup.nl>vbg.be@vbgroup.nl</a><br><a href= Basic Center</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top