public App() { // Application directory var assembly = Assembly.GetEntryAssembly(); ApplicationDirectory = new DirectoryInfo(Path.GetDirectoryName(assembly.Location)); // Data directory ApplicationDataDirectory = GetApplicationDataDirectory(); if (!ApplicationDataDirectory.Exists) { ApplicationDataDirectory.Create(); } }
private static void SetDirectories(OptionsBase options) { // Application directory var assembly = Assembly.GetEntryAssembly(); ApplicationDirectory = new DirectoryInfo(Path.GetDirectoryName(assembly !.Location) !); // Data directory if (string.IsNullOrWhiteSpace(options.AppDataPath)) { ApplicationDataDirectory = GetApplicationDataDirectory(); if (!ApplicationDataDirectory.Exists) { ApplicationDataDirectory.Create(); } } else { try { ApplicationDataDirectory = new DirectoryInfo(options.AppDataPath); if (!ApplicationDataDirectory.Exists) { ApplicationDataDirectory.Create(); } } catch { // We play it safe here and fall back to the default since at this point // in the app lifetime we cannot properly handle this error except crashing ApplicationDataDirectory = GetApplicationDataDirectory(); if (!ApplicationDataDirectory.Exists) { ApplicationDataDirectory.Create(); } } } // Temporary directory TemporaryDirectory = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "ModMyFactoryGUI")); if (!TemporaryDirectory.Exists) { TemporaryDirectory.Create(); } }
public App() { // Application directory var assembly = Assembly.GetEntryAssembly(); ApplicationDirectory = new DirectoryInfo(Path.GetDirectoryName(assembly.Location)); // Data directory ApplicationDataDirectory = GetApplicationDataDirectory(); if (!ApplicationDataDirectory.Exists) { ApplicationDataDirectory.Create(); } // Global shutdown command var shutdownCommand = ReactiveCommand.CreateFromTask(ShutdownAsync); ShutdownItemViewModel = new MenuItemViewModel(shutdownCommand, false, () => new CloseIcon(), "CloseMenuItem", "CloseHotkey"); }