public void EditReview(ReviewsModel model) { string[] lines = File.ReadAllLines(file); for (var i = 0; i < lines.Length; i++) { if (model.Id == Convert.ToInt32(lines[i].Split(';')[0])) { lines[i] = model.ToString(); break; } } File.WriteAllLines(file, lines); }
public void AddReview(ReviewsModel model) { FileInfo f = new FileInfo(file); if (f.Length <= 10) { model.Id = 1; } else { model.Id = Convert.ToInt32((File.ReadLines(file).Last()).Split(';')[0]) + 1; } using (StreamWriter writer = new StreamWriter(file, true)) { writer.WriteLine(model.ToString()); writer.Close(); } }