Check if file exists? help please.

Sinz

Member
Joined
Feb 14, 2008
Messages
6
Programming Experience
Beginner
hi there, i was wondering if there was a way to check if a file is already existing through using an if statement so:

if "company_records.txt" = True then

do nothing

else

create "company_records.txt"

could someone help me with the syntax for this please i know how to create a txt file but its the looking for a text file part i'm confused with.

any help is much appreciated, Sinz
 
try the following:

VB.NET:
Dim fileName As String = "C:\Hello.txt"

        If File.Exists(fileName) Then

            MessageBox.Show("file exists")
        Else

            MessageBox.Show("file does not exists")
        End If

HTH

to create the file

VB.NET:
 File.Create(pathname)
 
Last edited:
Back
Top