Created
June 12, 2012 07:08
-
-
Save NikkiBuck/2915803 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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