Save Data To Random Access Files?Sep 6, 2010
how do you save data stored in an array of records (structure) to a text file using StreamWriter? I currently have
Private Sub btnSaveToFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveToFile.Click
Dim sw As New StreamWriter(New FileStream("EmployeeDetails.txt", FileMode.Create, FileAccess.Write))
For Each record As EmployeeType In employees
but it doesn't work. My array is fixed and currently has 3 elements (for testing purposes). If I enter two records and add these to the structure I get the following data saved to the text file:
How do I stop unused elements of the array being included when writing to file? Should I use a dynamic array instead and if yes, how do you use dynamic arrays with structures?