public DirectoryAction(DirectoryElementAction action, DirectoryElement element, string item, string hub) { Action = action; Element = element; Item = item; Hub = hub; }
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 DirectoryElement CreateSubDir(DirectoryInfo dir) { var pathFromSourceDirectory = Working.GetSubDirPath(InstallDirPath, dir.FullName); var dirElement = new DirectoryElement { Id = $"IDD_{ Working.RemoveIllegalCharacters(pathFromSourceDirectory) }", Name = dir.Name, Directories = new List <DirectoryElement>() }; foreach (var subDir in dir.GetDirectories()) { dirElement.Directories.Add(CreateSubDir(subDir)); } return(dirElement); }
/// <summary> /// Gets the absolute path of the given path. /// </summary> /// <param name="element">Directory element. It can contain either relative or absolute value.</param> /// <exception cref="ConfigurationErrorsException">Throws when the directory has not been set.</exception> /// <returns>Returns the absolute path of the given path.</returns> public string GetAbsoluteDirectory(DirectoryElement element) { var path = element.Directory; if (String.IsNullOrWhiteSpace(path)) { throw new ConfigurationErrorsException("Directory has not been set"); } // Gets the absolute path using either Server.MapPath or Path.GetDirectoryName. var context = HttpContext.Current; if (context == null) { path = path.Replace("/", "\\"); if (path.Contains(":\\")) { return(path); } var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); path = String.Format(path.StartsWith("\\") ? "{0}{1}" : "{0}\\{1}", directory.TrimEnd('\\'), path.TrimEnd('\\')); } else { if (path.StartsWith("~/")) { path = context.Server.MapPath(path); } else { path = String.Format("{0}\\{1}", context.Server.MapPath("~/").TrimEnd('\\'), path.Replace('/', '\\').Trim('\\')); } } return(path); }