sequential file
Using a sequential file, an application can allow users to store data into a text file for permanent storage. It also allows an application to read the data from the text file.
The data is written and read from a text file in a sequential order, and that is why it is called sequential file.
For example, you have a list of persons' names including Pat, Tom, and Sue to write into a sequential file. VB .Net uses the StreamWriter class to carry out the operation.
- The StreamWriter of VB .Net will write Pat into the file, so Pat is the first record.
- Then the StreamWriter will write Tom into the file, so Tom will be the second record after Pat.
- Lastly, the StreamWriter will write Sue to the file, so Sue will be the third, Tom will stay at the second, and Sue will stay at the first.
The diagram below shows how the status of data change as the StreamWriter writes each name into the sequential file.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
There are three basic operations in sequential files.
- Creating and Writing data into a file
- Appending or adding data into an existing file
- Reading data from an existing file