public static void Remove(string path, QTHT qtht) { if (File.Exists(path)) { List<string> rs = new List<string>(); var lines = File.ReadAllLines(path); foreach(var line in lines) { var data = QTHT.Parse(line); if(data.ID != qtht.ID) { rs.Add(line); } } File.WriteAllLines(path, rs); } else { throw new Exception("File du lieu khong ton tai!"); } }
/// <summary> /// lay danh sach sinh vien vao file /// </summary> /// <param name="path">duong dan file</param> /// <param name="idStudent"></param> /// <returns></returns> public static List<QTHT> getQTHT(string path,string idStudent) { List<QTHT> list = new List<QTHT>(); if (File.Exists(path)) { var lines = File.ReadAllLines(path); foreach (var line in lines) { var qtht = QTHT.Parse(line); if (qtht.IDStudent == idStudent) { list.Add(qtht); } } return list; } else { return null; } }