예제 #1
0
        public static bool Load(string filename, ref TestTime obj)
        {
            bool       b          = true;
            FileStream fileStream = null;

            try
            {
                fileStream = File.OpenRead(filename);
                BinaryFormatter binaryFormatter = new BinaryFormatter();

                obj = binaryFormatter.Deserialize(fileStream) as TestTime;
            }
            catch (FileNotFoundException ex)
            {
                obj.Log = new List <string>();
                b       = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
                b = false;
            }
            finally
            { if (fileStream != null)
              {
                  fileStream.Close();
              }
            }

            return(b);
        }
예제 #2
0
        public static bool Save(string filename, TestTime obj)
        {
            bool       b          = true;
            FileStream fileStream = null;

            try
            {
                fileStream = File.Create(filename);
                BinaryFormatter binaryFormatter = new BinaryFormatter();

                binaryFormatter.Serialize(fileStream, obj);
            }
            catch (Exception ex)
            { Console.WriteLine("Exception: " + ex.Message);
              b = false; }
            finally
            { if (fileStream != null)
              {
                  fileStream.Close();
              }
            }

            return(b);
        }