Пример #1
0
        public static bool BinarizeToFile(string targetFilePath, IBinarizable stream)
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(targetFilePath, FileMode.Create);
                using (var bw = new BinaryWriter(fs))
                {
                    fs = null;
                    stream.Binarize(bw);
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                return(false);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }

            return(true);
        }
Пример #2
0
        public static bool DebinarizeFromFile(string targetFilePath, IBinarizable stream)
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(targetFilePath, FileMode.Open);
                using (var br = new BinaryReader(fs))
                {
                    fs = null;
                    stream.Debinarize(br);
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                return(false);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }

            return(true);
        }
Пример #3
0
        public static void DebinarizeFromFile(string targetFilePath, IBinarizable stream)
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(targetFilePath, FileMode.Open);
                using (var br = new BinaryReader(fs))
                {
                    fs = null;
                    stream.Debinarize(br);
                }
            }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }
        }
Пример #4
0
        public static void BinarizeToFile(string targetFilePath, IBinarizable stream)
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(targetFilePath, FileMode.Create);
                using (var bw = new BinaryWriter(fs))
                {
                    fs = null;
                    stream.Binarize(bw);
                }
            }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }
        }