The file object represents a file, and there are some very useful ways to verify the existence of a file and rename and delete a file. For example:
Dim FL as File
Fl=new File ("Foo.txt")
if (fl. Exists) ' If the file Exists
Fl. Delete ' Delete it
End If
The user can also use the file object to get a FileStream object and then read and write the file data by using the FileStream object:
Dim TS as TextStream
Dim FS as FileStream
TS=FL. OpenText ' Open a text file for reading
FS=FL. OpenRead ' Open any file for reading
(1) Read a text file (textfile)
To read a text file, the user can use the file object to get a StreamReader object and then use the text stream's Read method:
Dim TS as StreamReader
TS=FL. OpenText ()
S=ts.readline
(2) Write a text document (write a-text file)
To create and write a text file, the user can get a Streamwrite object using the CreateText method, and then do the action, such as:
Dim SW as StreamWriter
SW=FL. CreateText
Sw.writeline ("Write text into file")
If a user wants to operate on a file that already exists, you can use an object with logical parameters to do so:
Sw=new StreamWriter (Path,true)