private static void MoveTo(string fullPath, string destinationFolderName, bool isAppendNumber, bool isAppendDate) { StringBuilder fileNameWithouExtensionBuilder = new StringBuilder(Path.GetFileNameWithoutExtension(fullPath)); string destinationFolderFullName = Path.Combine(Path.GetDirectoryName(fullPath), destinationFolderName); DirectoryInfo destinationFolder = null; if (Directory.Exists(destinationFolderFullName)) { destinationFolder = new DirectoryInfo(destinationFolderFullName); } else { destinationFolder = Directory.CreateDirectory(destinationFolderFullName); } if (isAppendNumber) { fileNameWithouExtensionBuilder.Append("Id"); Id++; using (CustomConfigSectionManager customConfigManager = new CustomConfigSectionManager()) { customConfigManager.UpdateCounter(Id); } fileNameWithouExtensionBuilder.Append(Id); } if (isAppendDate) { fileNameWithouExtensionBuilder.Append("Date"); fileNameWithouExtensionBuilder.Append(DateTime.Now.Date.ToLongDateString()); } SafeMoveTo(fullPath, destinationFolderFullName, fileNameWithouExtensionBuilder.ToString(), Path.GetExtension(fullPath)); }
private static void AddRule(RuleElement rule) { using (CustomConfigSectionManager customConfigManager = new CustomConfigSectionManager()) { customConfigManager.AddRule(rule); } if (Rules == null) { Rules = new RuleElementCollection(); } Rules.Add(rule); }
private static void UpdateCulture(Cultures name) { using (CustomConfigSectionManager customConfigManager = new CustomConfigSectionManager()) { customConfigManager.UpdateCulture(new CultureElement { Name = name }); } CultureInfo culture = new CultureInfo(Convert.ToInt32(name.ToString("d"))); Thread.CurrentThread.CurrentUICulture = culture; }
private static void AddDirectory(DirectoryElement directory) { using (CustomConfigSectionManager customConfigManager = new CustomConfigSectionManager()) { customConfigManager.AddDirectory(directory); } if (watchersLst == null) { watchersLst = new List <FileSystemWatcher>(); } watchersLst.Add(CreateWatcher(directory.Path, Watcher_Changed)); }
private static void Init() { CustomConfigSection customConfig = (CustomConfigSection)ConfigurationManager.GetSection("CustomConfigSection"); using (CustomConfigSectionManager customConfigSectionManager = new CustomConfigSectionManager()) { CultureElement culture = customConfigSectionManager.GetCurrentCulture(); Thread.CurrentThread.CurrentUICulture = new CultureInfo(Convert.ToInt32(culture.Name.ToString("D"))); Id = customConfigSectionManager.GetCurrentCount(); Rules = customConfigSectionManager.GetRules(); watchersLst = new List <FileSystemWatcher>(); foreach (DirectoryElement item in customConfigSectionManager.GetDirectories()) { watchersLst.Add(CreateWatcher(item.Path, Watcher_Changed)); } } }