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

            // Save As...
            if (!string.IsNullOrEmpty(filename))
            {
                _umsbt.Save(FileInfo.Create(), plain);
                _umsbt.Close();
            }
            else
            {
                // Create the temp file
                _umsbt.Save(File.Create(FileInfo.FullName + ".tmp"), plain);
                _umsbt.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 SaveResult Save(string filename = "")
        {
            SaveResult result = SaveResult.Success;

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

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

            return(result);
        }