Ejemplo n.º 1
0
        public void Save(string filename = "")
        {
            if (!string.IsNullOrEmpty(filename))
            {
                FileInfo = new FileInfo(filename);
            }

            // Save As...
            if (!string.IsNullOrEmpty(filename))
            {
                _sarc.Save(FileInfo.Create());
                _sarc.Close();
            }
            else
            {
                // Create the temp file
                _sarc.Save(File.Create(FileInfo.FullName + ".tmp"));
                _sarc.Close();
                // Delete the original
                FileInfo.Delete();
                // Rename the temporary file
                File.Move(FileInfo.FullName + ".tmp", FileInfo.FullName);
            }

            // Reload the new file to make sure everything is in order
            Load(FileInfo.FullName);
        }
Ejemplo n.º 2
0
        public void Save(string filename = "")
        {
            if (!string.IsNullOrEmpty(filename))
            {
                FileInfo = new FileInfo(filename);
            }

            // Save As...
            if (!string.IsNullOrEmpty(filename))
            {
                var ms = new MemoryStream();
                _sarc.Save(ms, true);
                _sarc.Close();
                using (var bw = new BinaryWriterX(FileInfo.Create()))
                {
                    bw.Write(BitConverter.GetBytes((int)ms.Length).Reverse().ToArray());
                    ms.Position = 0;
                    bw.Write(ZLib.Compress(ms));
                }
            }
            else
            {
                // Create the temp file
                var ms = new MemoryStream();
                _sarc.Save(ms, true);
                _sarc.Close();
                using (var bw = new BinaryWriterX(File.Create(FileInfo.FullName + ".tmp")))
                {
                    bw.Write(BitConverter.GetBytes((int)ms.Length).Reverse().ToArray());
                    ms.Position = 0;
                    bw.Write(ZLib.Compress(ms));
                }
                // Delete the original
                FileInfo.Delete();
                // Rename the temporary file
                File.Move(FileInfo.FullName + ".tmp", FileInfo.FullName);
            }

            // Reload the new file to make sure everything is in order
            Load(FileInfo.FullName);
        }
Ejemplo n.º 3
0
 public void Unload()
 {
     _sarc?.Close();
 }