public static bool Load(string filename, ref DoubledLinkedList <T> obj) { System.IO.FileStream fileStream = null; bool flag = true; try { fileStream = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read); BinaryFormatter binaryFormatter = new BinaryFormatter(); obj = binaryFormatter.Deserialize(fileStream) as DoubledLinkedList <T>; } catch (Exception ex) { Console.WriteLine("Исключение: " + ex.Message); flag = false; } finally { if (fileStream != null) { fileStream.Close(); } } return(flag); }
public bool Save(string filename) { DoubledLinkedList <T> obj = this; System.IO.FileStream fileStream = null; bool flag = true; try { fileStream = new System.IO.FileStream(filename, System.IO.FileMode.Create, System.IO.FileAccess.Write); BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(fileStream, obj); } catch (Exception ex) { Console.WriteLine("Исключение: " + ex.Message); flag = false; } finally { if (fileStream != null) { fileStream.Close(); } } return(flag); }