Skip to content

Instantly share code, notes, and snippets.

@NikkiBuck
Created June 12, 2012 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikkiBuck/2915784 to your computer and use it in GitHub Desktop.
Save NikkiBuck/2915784 to your computer and use it in GitHub Desktop.
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