Help with saving from an array to a file

Ub3r-L33ch

Member
Joined
Sep 20, 2005
Messages
11
Programming Experience
Beginner
I'm doing another assignment for class and we have to use arrays to store information, save it to a file, load the file, and use the information in the file to display results.

Anyways, whenever I save the file it keeps adding to the file each time I run the program and save new data to the file. I just want it to only save the information 1 time when its run, each time after that I want it to overwrite the file and only store the new data.

My teacher said something about using the "peek" method to check for end of file. I havent quite figured that out yet.

Thanks for any help.
 
re

VB.NET:
Dim fs As New FileStream("c:/file.txt", FileMode.Open, FileAccess.Write)

        Dim writer As New StreamWriter(fs)

        writer.WriteLine("write a line")
        writer.Write("write text..")

        writer.Close()
 
Back
Top