public void SaveAs(String fileName) { var fullPath = Path.GetFullPath(fileName); if (File.Exists(fullPath) && (File.GetAttributes(fullPath) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { ActiveView.ShowMessage("This file is read only."); } else { //if file path is the same as our current path, skip creating new file and just save if (String.Compare( Path.GetFullPath(Database.Path), fullPath, StringComparison.InvariantCultureIgnoreCase) != 0) { Database.CopyAs(fileName, true); } //save after copying this.Save(); AppState.AddRecentFile(fullPath); this.MainWindow.Text = System.IO.Path.GetFileName(this.Database.Path); } }
public virtual void OpenFile(String filePath) { Analytics.TrackEvent(nameof(OpenFile), new Dictionary <string, string> { { "filePath", Path.GetFileName(filePath) } }); var extension = System.IO.Path.GetExtension(filePath).ToLowerInvariant(); if (extension == Strings.CRUISE_FILE_EXTENTION || extension == Strings.CRUISE_TEMPLATE_FILE_EXTENTION) { InitializeDAL(filePath); } else { ActiveView.ShowMessage("Invalid file name", null); } }
protected void InitializeDAL(string path) { //start wait cursor in case this takes a long time ActiveView.ShowWaitCursor(); try { Database = new DAL(path); } //catch (CruiseDAL.DatabaseShareException) //{ // ActiveView.ShowMessage("File can not be opened in multiple applications"); //} catch (FMSC.ORM.ReadOnlyException) { ActiveView.ShowMessage("Unable to open file because it is read only"); } catch (FMSC.ORM.IncompatibleSchemaException ex) { ActiveView.ShowMessage("File is not compatible with this version of Cruise Manager: " + ex.Message); } catch (FMSC.ORM.SQLException ex) { ActiveView.ShowMessage("Unable to open file : " + ex.GetType().Name); } catch (System.IO.IOException ex) { ActiveView.ShowMessage("Unable to open file : " + ex.GetType().Name); } catch (System.Exception e) { if (!ExceptionHandler.Handel(e)) { throw; } } finally { ActiveView.ShowDefaultCursor(); } }