protected virtual string GetSnapshotFileName(string directory, ISnapshot snapshot) { Argument.IsNotNull(() => snapshot); var snapshotFile = Path.Combine(directory, $"{snapshot.Title.GetSlug()}{SnapshotExtension}"); return(snapshotFile); }
public void CombinePath_NoValues() { // Call method string result = Path.Combine(); // Validate Assert.AreEqual(@"", result); }
private string GetExampleFileName(string relativeFileName) { var rootDirectory = AssemblyDirectoryHelper.GetCurrentDirectory(); var path = Path.Combine(rootDirectory, "Models", relativeFileName); return(path); }
public void GetApplicationDataDirectory_CompanyAndApp() { string expected = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Assembly.GetExecutingAssembly().Company(), Assembly.GetExecutingAssembly().Product()); string result = Path.GetApplicationDataDirectory(Assembly.GetExecutingAssembly().Company(), Assembly.GetExecutingAssembly().Product()); Assert.AreEqual(expected, result); }
public KeyboardMappingsService(ICommandManager commandManager, IXmlSerializer xmlSerializer) { Argument.IsNotNull(() => commandManager); Argument.IsNotNull(() => xmlSerializer); _commandManager = commandManager; _xmlSerializer = xmlSerializer; _fileName = Path.Combine(Path.GetApplicationDataDirectory(), "keyboardmappings.xml"); }
public void GetApplicationDataDirectoryForAllUsers_AppOnly() { string expected = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Assembly.GetExecutingAssembly().Product()); string result = Path.GetApplicationDataDirectoryForAllUsers(Assembly.GetExecutingAssembly().Product()); Assert.AreEqual(expected, result); }
public FileSystemSnapshotStorageService(IDirectoryService directoryService, IFileService fileService) { Argument.IsNotNull(() => directoryService); Argument.IsNotNull(() => fileService); _directoryService = directoryService; _fileService = fileService; Directory = Path.Combine(Path.GetApplicationDataDirectory(), "snapshots"); }
private static string GetLogDirectory() { var appDataService = ServiceLocator.Default.ResolveType <IAppDataService>(); var directory = Path.Combine(appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming), "log"); Directory.CreateDirectory(directory); return(directory); }
public void CombinePath_1Value() { // Declare variables string path1 = @"C:\Windows"; // Call method string result = Path.Combine(path1); // Validate Assert.AreEqual(@"C:\Windows", result); }
public void CombinePath_OneNullValue() { // Declare variables string path1 = @"C:\"; string path2 = null; string path3 = @"Program Files"; // Call method string result = Path.Combine(path1, path2, path3); // Validate Assert.AreEqual(@"C:\Program Files", result); }
public void Initialize() { // Determine test directory _testDirectory = Path.Combine(System.IO.Path.GetTempPath(), "PathTest"); // Delete directory, than create it if (Directory.Exists(_testDirectory)) { Directory.Delete(_testDirectory, true); } Directory.CreateDirectory(_testDirectory); }
public static string GetRootDirectory() { var directory = Path.GetApplicationDataDirectory(); directory = Path.Combine(directory, "search"); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } return(directory); }
public RecentlyUsedItemsService(IXmlSerializer xmlSerializer) { Argument.IsNotNull(() => xmlSerializer); _xmlSerializer = xmlSerializer; _fileName = Path.Combine(Path.GetApplicationDataDirectory(), "recentlyused.xml"); _items = new RecentlyUsedItems(); MaximumItemCount = 10; Load(); }
public FileSystemSnapshotStorageService(IDirectoryService directoryService, IFileService fileService, IAppDataService appDataService) { Argument.IsNotNull(() => directoryService); Argument.IsNotNull(() => fileService); Argument.IsNotNull(() => appDataService); _directoryService = directoryService; _fileService = fileService; _appDataService = appDataService; Directory = Path.Combine(_appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming), "snapshots"); }
public void CombinePath_3Values() { // Declare variables string path1 = @"C:\"; string path2 = @"Windows"; string path3 = @"System"; // Call method string result = Path.Combine(path1, path2, path3); // Validate Assert.AreEqual(@"C:\Windows\System", result); }
public void CombinePath_EmptyValues() { // Declare variables string path1 = @""; string path2 = @""; string path3 = @""; // Call method string result = Path.Combine(path1, path2, path3); // Validate Assert.AreEqual(@"", result); }
private static string GetWindowStorageFile(this Window window) { Argument.IsNotNull(() => window); var appData = Path.GetApplicationDataDirectory(); var directory = Path.Combine(appData, "windows"); Directory.CreateDirectory(directory); var file = Path.Combine(directory, $"{window.GetType().FullName}.dat"); return(file); }
public static void CleanUpAllLogTypeFiles(bool keepCleanInRealTime = false) { var directory = Path.Combine(Path.GetApplicationDataDirectory(), "log"); foreach (var prefix in LogFilePrefixes.All) { var filter = prefix + "*.log"; CleanUpLogFiles(directory, filter); if (keepCleanInRealTime) { ConfigureFileSystemWatcher(directory, filter); } } }
public static ILogListener CreateFileLogListener(string prefix) { Argument.IsNotNull(() => prefix); var directory = GetLogDirectory(); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var fileName = Path.Combine(directory, prefix + "_{Date}_{Time}_{ProcessId}"); var fileLogListener = new Orchestra.Logging.FileLogListener(fileName, 10 * 1024); return(fileLogListener); }
public static ILogListener CreateFileLogListener(string prefix) { Argument.IsNotNull(() => prefix); var directory = Path.Combine(Path.GetApplicationDataDirectory(), "log"); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var fileName = Path.Combine(directory, prefix + "_{Date}_{Time}_{ProcessId}"); var fileLogListener = new FileLogListener(fileName, 10 * 1024); return(fileLogListener); }
public RecentlyUsedItemsService(IXmlSerializer xmlSerializer, IFileService fileService, IAppDataService appDataService) { Argument.IsNotNull(() => xmlSerializer); Argument.IsNotNull(() => fileService); Argument.IsNotNull(() => appDataService); _xmlSerializer = xmlSerializer; _fileService = fileService; _appDataService = appDataService; _fileName = Path.Combine(appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming), "recentlyused.xml"); _items = new RecentlyUsedItems(); MaximumItemCount = 10; Load(); }
public KeyboardMappingsService(ICommandManager commandManager, IXmlSerializer xmlSerializer, IFileService fileService, IAppDataService appDataService) { Argument.IsNotNull(() => commandManager); Argument.IsNotNull(() => xmlSerializer); Argument.IsNotNull(() => fileService); Argument.IsNotNull(() => appDataService); _commandManager = commandManager; _xmlSerializer = xmlSerializer; _fileService = fileService; _appDataService = appDataService; _fileName = Path.Combine(appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming), "keyboardmappings.xml"); AdditionalKeyboardMappings = new List <KeyboardMapping>(); }
protected override void OnOperationFinished(object sender, PackageOperationEventArgs e) { if (e.PackageOperationType != PackageOperationType.Uninstall) { return; } if (!Directory.Exists(e.InstallPath)) { return; } var fileName = $"{e.PackageDetails.Id}.deleteme"; var fullName = Path.Combine(e.InstallPath, fileName); using (File.Create(fullName)) { } }
public void GetApplicationDataDirectory_CompanyAndAppAndTestDirectoryCreation() { // Set up directory string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Assembly.GetExecutingAssembly().Company(), Assembly.GetExecutingAssembly().Product()); // Make sure that the directory does not exist if (Directory.Exists(directory)) { Directory.Delete(directory); } // Now create the directory string result = Path.GetApplicationDataDirectory(Assembly.GetExecutingAssembly().Company(), Assembly.GetExecutingAssembly().Product()); // Check if the directory exists Assert.AreEqual(directory, result); Assert.IsTrue(Directory.Exists(result)); }
private static string GetWindowStorageFile(this Window window, string tag) { Argument.IsNotNull(() => window); var appData = Catel.IO.Path.GetApplicationDataDirectory(); var directory = Path.Combine(appData, "windows"); Directory.CreateDirectory(directory); var tagToUse = string.Empty; if (!string.IsNullOrWhiteSpace(tag)) { tagToUse = $"_{tag.GetSlug()}"; } var file = Path.Combine(directory, $"{window.GetType().FullName}{tagToUse}.dat"); return(file); }
private static string GetWindowStorageFile(this Window window, string tag) { Argument.IsNotNull(() => window); var appDataService = ServiceLocator.Default.ResolveType <IAppDataService>(); var appData = appDataService.GetApplicationDataDirectory(Catel.IO.ApplicationDataTarget.UserRoaming); var directory = Path.Combine(appData, "windows"); Directory.CreateDirectory(directory); var tagToUse = string.Empty; if (!string.IsNullOrWhiteSpace(tag)) { tagToUse = $"_{tag.GetSlug()}"; } var file = Path.Combine(directory, $"{window.GetType().FullName}{tagToUse}.dat"); return(file); }