コード例 #1
0
ファイル: XpckManager.cs プロジェクト: benladen/Kuriimu
        public void Save(string filename = "")
        {
            if (!string.IsNullOrEmpty(filename))
            {
                FileInfo = new FileInfo(filename);
            }

            // Save As...
            if (!string.IsNullOrEmpty(filename))
            {
                _xpck.Save(FileInfo.Create());
                _xpck.Close();
            }
            else
            {
                // Create the temp file
                _xpck.Save(File.Create(FileInfo.FullName + ".tmp"));
                _xpck.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);
        }
コード例 #2
0
ファイル: XpckManager.cs プロジェクト: getov/Kuriimu
        public SaveResult Save(string filename = "")
        {
            SaveResult result = SaveResult.Success;

            if (filename.Trim() != string.Empty)
            {
                _fileInfo = new FileInfo(filename);
            }

            try
            {
                // Save As...
                if (!string.IsNullOrWhiteSpace(filename))
                {
                    _xpck.Save(File.Create(_fileInfo.FullName));
                }
                else
                {
                    // Create the temp file
                    _xpck.Save(File.Create(_fileInfo.FullName + ".tmp"));
                    // 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);
            }
            catch (Exception)
            {
                result = SaveResult.Failure;
            }

            return(result);
        }