public void CreateFolders(FolderConfiguration config, string mediaFolder) { IList <string> paths = new List <string>(); var type = config.GetType(); foreach (var property in type.GetProperties() .Where(x => x.CustomAttributes.Any(y => y.AttributeType == typeof(FolderAttribute))).ToList()) { var t = property.GetValue(config); var baseFolder = (BaseFolder)property.GetValue(config); GetSubFolder(baseFolder, paths); } foreach (var path in paths) { Directory.CreateDirectory(Path.Combine(mediaFolder, path)); } }