static Dir ScanWebFiles(string targetPath, string folderPath, IISVirtualDir iis) { var result = new Dir(targetPath, iis) { IsInstallDir = true }; result.AddFiles(System.IO.Directory.EnumerateFiles(folderPath).Select(_ => new File(_)).ToArray()); result.AddDirs(System.IO.Directory.EnumerateDirectories(folderPath).Select(_ => ScanFiles(_.Split('\\').Last(), _)).ToArray()); // Add Logs var tempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "WebServer.log"); System.IO.File.Create(tempFilePath); result.AddDirs(new Dir[] { new Dir("Logs", new DirPermission("Everyone", GenericPermission.All), new File(tempFilePath)) }); return(result); }
static Dir ScanFiles(string targetPath, string folderPath, Predicate <string> exclude = null) { var result = new Dir(targetPath); if (exclude == null) { result.AddFiles(System.IO.Directory.EnumerateFiles(folderPath).Select(_ => new File(_)).ToArray()); } else { result.AddFiles(System.IO.Directory.EnumerateFiles(folderPath).Where(_ => !exclude(_)).Select(_ => new File(_)).ToArray()); } result.AddDirs(System.IO.Directory.EnumerateDirectories(folderPath).Select(_ => ScanFiles(_.Split('\\').Last(), _, exclude)).ToArray()); return(result); }