private TreeNodeCollection AddFolders(string parent, FormDataCollection queryStrings) { var treeNodeCollection = new TreeNodeCollection(); var rootFolderPath = IOHelper.MapPath("~"); var folders = UmbracoFlareFileHelper.GetFolders(parent); foreach (var folder in folders) { var folderFullName = folder.FullName.Replace(rootFolderPath, "").Replace("\\", "/"); var folderHasFiles = folder.EnumerateDirectories().Any() || UmbracoFlareFileHelper.GetFiles(folderFullName).Any(); var treeNode = CreateTreeNode(folderFullName, parent, queryStrings, folder.Name, "icon-folder", folderHasFiles); treeNodeCollection.Add(treeNode); } return(treeNodeCollection); }
private TreeNodeCollection AddFiles(string folder, FormDataCollection queryStrings) { var path = IOHelper.MapPath(folder); var rootPath = IOHelper.MapPath("~"); var treeNodeCollection = new TreeNodeCollection(); var files = UmbracoFlareFileHelper.GetFiles(folder); foreach (var file in files) { var nodeTitle = file.Name; var filePath = file.FullName.Replace(rootPath, "").Replace("\\", "/"); var treeNode = CreateTreeNode(filePath, path, queryStrings, nodeTitle, "icon-document", false); treeNodeCollection.Add(treeNode); } return(treeNodeCollection); }
public IEnumerable <string> GetFilePaths(IEnumerable <string> filesOrFolders) { var rootOfApplication = IOHelper.MapPath("~/"); var filePaths = new List <string>(); var filesOrFoldersTest = filesOrFolders.HasAny() ? filesOrFolders.Where(x => x.HasValue()) : Enumerable.Empty <string>(); foreach (var fileOrFolder in filesOrFoldersTest) { var fileOrFolderPath = IOHelper.MapPath(fileOrFolder); var fileAttributes = File.GetAttributes(fileOrFolderPath); if (fileAttributes.Equals(FileAttributes.Directory)) { var filesInTheFolder = UmbracoFlareFileHelper.GetFilesIncludingSubDirs(fileOrFolderPath); var files = filesInTheFolder.Where(x => x.HasValue()); foreach (var file in files) { if (file.Directory == null) { continue; } var directory = file.Directory.FullName.Replace(rootOfApplication, string.Empty); var filePath = $"{directory.Replace("\\", "/")}/{file.Name}"; filePaths.Add(filePath); } } else { if (!File.Exists(fileOrFolderPath)) { _umbracoLoggingService.LogWarn <CloudflareUmbracoApiController>($"Could not find file with the path {fileOrFolderPath}"); continue; } filePaths.Add(fileOrFolder.StartsWith("/") ? fileOrFolder.TrimStart('/') : fileOrFolder); } } return(filePaths); }