Esempio n. 1
0
        // called on a clean shutdown, removes all autosave files
        public void RemoveAll()
        {
            try {
                // delete autosaveindex
                SharingViolations.Wrap(() => File.Delete(AutoSaveIndexFile(GetCurrentAutoSaveIndex())));
            }
            catch (Exception ex)
            {
                Log.Error(ex, "{class} {method} {message}", nameof(AutoSaver), nameof(RemoveAll), $"Error deleting AutoSaveIndex: {ex.Message}");
            }

            // delete autosave files
            // TODO - should I only delete the files for this instance of DAX Studio??
            //        at the moment this removes all auto save files from all instances
            //        so if one instance crashes and another is still open closing the open one
            //        will wipe out any files from the crashed instance...
            FileInfo[] files;
            try
            {
                System.IO.DirectoryInfo di = new DirectoryInfo(ApplicationPaths.AutoSavePath);
                files = di.GetFiles();

                foreach (FileInfo file in files)
                {
                    try
                    {
                        file.Delete();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "{class} {method} {message}", nameof(AutoSaver), nameof(RemoveAll), $"Error deleting AutoSave file '{file.FullName}' - {ex.Message}");
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "{class} {method} {message}", nameof(AutoSaver), nameof(RemoveAll), $"Error getting AutoSave file collection: {ex.Message}");
            }

            // remove entry from master auto save index
            if (_masterAutoSaveIndex.ContainsKey(CurrentProcessId))
            {
                _masterAutoSaveIndex.Remove(CurrentProcessId);
            }
        }
Esempio n. 2
0
        // called on a clean shutdown, removes all autosave files
        internal static void RemoveAll()
        {
            // delete autosaveindex
            SharingViolations.Wrap(() => File.Delete(AutoSaveIndexFile(GetCurrentAutoSaveIndex())));

            // delete autosave files
            // TODO - should I only delete the files for this instance of DAX Studio??
            //        at the moment this removes all auto save files from all instances
            //        so if one instance crashes and another is still open closing the open one
            //        will wipe out any files from the crashed instance...
            System.IO.DirectoryInfo di = new DirectoryInfo(AutoSaveFolder);
            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }

            // remove entry from master auto save index
            _masterAutoSaveIndex.Remove(CurrentProcessId);
        }