public override void Run() { IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; if (window != null) { if (window.ViewContent.IsViewOnly) { return; } if (window.ViewContent.FileName == null) { SaveFileAs sfa = new SaveFileAs(); sfa.Run(); } else { FileAttributes attr = FileAttributes.ReadOnly | FileAttributes.Directory | FileAttributes.Offline | FileAttributes.System; if (File.Exists(window.ViewContent.FileName) && (File.GetAttributes(window.ViewContent.FileName) & attr) != 0) { SaveFileAs sfa = new SaveFileAs(); sfa.Run(); } else { ProjectService.MarkFileDirty(window.ViewContent.FileName); FileUtility.ObservedSave(new FileOperationDelegate(window.ViewContent.Save), window.ViewContent.FileName, FileErrorPolicy.ProvideAlternative); } } } }
public static void Save(OpenedFile file) { if (file.IsUntitled) { SaveFileAs.Save(file); } else { FileAttributes attr = FileAttributes.ReadOnly | FileAttributes.Directory | FileAttributes.Offline | FileAttributes.System; if (File.Exists(file.FileName) && (File.GetAttributes(file.FileName) & attr) != 0) { SaveFileAs.Save(file); } else { FileUtility.ObservedSave(new NamedFileOperationDelegate(file.SaveToDisk), file.FileName, FileErrorPolicy.ProvideAlternative); } } }