Ejemplo n.º 1
0
        public static bool Load(string filename, ref TestTime obj)
        {
            FileStream file   = null;
            bool       result = true;

            try
            {
                file = new FileStream(filename, FileMode.Open);
                BinaryFormatter formatter = new BinaryFormatter();
                obj = formatter.Deserialize(file) as TestTime;
            }
            catch (Exception e)
            {
                Console.WriteLine($"_3DiagMatricesCS.Load: Failed to load log from file. Error message: {e.Message}");
                result = false;
            }
            finally
            {
                if (file != null)
                {
                    file.Close();
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        //---------------
        // Static methods
        //---------------
        public static bool Save(string filename, TestTime obj)
        {
            FileStream file   = null;
            bool       result = true;

            try
            {
                file = new FileStream(filename, FileMode.Create);
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(file, obj);
            }
            catch (Exception e)
            {
                Console.WriteLine($"_3DiagMatricesCS.Save: Failed to save log to file. Error message: {e.Message}");
                result = false;
            }
            finally
            {
                if (file != null)
                {
                    file.Close();
                }
            }
            return(result);
        }