Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public void SavingFile()
{
StreamWriter writer = new StreamWriter("books.txt");
foreach (Book book in books)
{
writer.WriteLine(book.ToString());
}
}
public void LoadingFile()
{
const char DELIM = '\t';
string recordIn = "";
string part;
FileStream file = new FileStream("books.txt", FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(file);
while (reader.Peek() != -1)
{
recordIn = reader.ReadLine();
part = recordIn.Split(DELIM);
part[0] = ISBN Isbn(part[0]);
part[1] = book.LastName[1];
part[2] = book.FirstName;
part[3] = book.Title;
part[4] = book.Year;
part[5] = book.Price;
}
if (book.Valid() && book.Normalize())
{
book.Add(books.txt)
}
reader.Close();
file.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment