// =========================================================================================================== /// <summary> /// Creates a tokenized version of the specified folder based on the available tokens /// </summary> /// <param name="folderPath">The path of the folder that needs to be tokenized</param> /// <returns>The path of the tokenized folder</returns> // =========================================================================================================== public string TokenizeFolder(string folderPath) { string tokenizedFolderPath = null; if (this.Tokens.Count > 0) { logger.Info("Tokenizing folder '{0}' to destination '{0}{1}'", Path.GetFileName(folderPath), TOKENIZED_FOLDER_EXTENSION); // -------------------------------------------------- // Validates the source folder // -------------------------------------------------- if (!Directory.Exists(folderPath)) { throw new DirectoryNotFoundException(string.Format(ERROR_FOLDER_NOT_FOUND, folderPath)); } // -------------------------------------------------- // Copies the source folder to it's tokenized destination // -------------------------------------------------- tokenizedFolderPath = folderPath + TOKENIZED_FOLDER_EXTENSION; FilesUtility.CopyDirectory(folderPath, tokenizedFolderPath); // -------------------------------------------------- // Tokenizes the destination folder recursively // -------------------------------------------------- TokenizeFolderRecursive(tokenizedFolderPath); logger.Info("Folder '{0}' tokenized with success to destination '{0}{1}'", Path.GetFileName(folderPath), TOKENIZED_FOLDER_EXTENSION); } return(tokenizedFolderPath); }
// =========================================================================================================== /// <summary> /// Creates a tokenized version of the specified folder based on the available tokens /// </summary> /// <param name="folderPath">The path of the folder that needs to be tokenized</param> /// <returns>The path of the tokenized folder</returns> // =========================================================================================================== public string TokenizeFolder(string folderPath) { string tokenizedFolderPath = null; if (this.Tokens.Count > 0) { logger.Info("Tokenizing folder '{0}' to destination '{0}{1}'", Path.GetFileName(folderPath), TOKENIZED_FOLDER_EXTENSION); // -------------------------------------------------- // Validates the source folder // -------------------------------------------------- if (!Directory.Exists(folderPath)) { throw new DirectoryNotFoundException(string.Format(ERROR_FOLDER_NOT_FOUND, folderPath)); } // -------------------------------------------------- // Loads the ignored folders // -------------------------------------------------- ignoredFolders = ConfigurationManager.AppSettings[APP_SETTING_IGNORED_FOLDERS].Split('|').Where(x => !string.IsNullOrEmpty(x)).Select(x => Path.Combine(folderPath.ToLower(), x.ToLower())).ToList <string>(); // -------------------------------------------------- // Copies the source folder to it's tokenized destination // -------------------------------------------------- tokenizedFolderPath = folderPath + TOKENIZED_FOLDER_EXTENSION; FilesUtility.CopyDirectory(folderPath, tokenizedFolderPath, ignoredFolders); // -------------------------------------------------- // Tokenizes the destination folder recursively // -------------------------------------------------- TokenizeFolderRecursive(tokenizedFolderPath); logger.Info("Folder '{0}' tokenized with success to destination '{0}{1}'", Path.GetFileName(folderPath), TOKENIZED_FOLDER_EXTENSION); } return(tokenizedFolderPath); }