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

file management problem

Status
Not open for further replies.

TAnselm

Vendor
Mar 10, 2006
791
0
0
US
How do you check to see if a data file exists before trying to open it?

This is what I want to do... when the program boots up it will check to see if this is the first time it is run or if a data file already exists. If the file exists it will open and read from it. If not it will go to another portion of the program to gather information from the user and write to a new data file before continuing. Please let me know where I'm going wrong.

NOTE: I'm using visual basic 6.0 and i'm getting run-time error 424; "Object Required"

Here is the code I'm trying to use:

If File.Exists ("c:\test.txt") Then
Open "c:\test.txt" For Input As #1
inputframe_frm.Visible = True
Else
Open "c:\test.txt" For Output As #1
test_frm.Visible = True
End If


 
See the DIR() function in the Help file (type DIR and hit F1)
 
Thank you...
I will try when I get home from work.
 
Thanks all the DIR() function worked like a charm.

If DIR(path) <> "" then...

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top