void OutputDirNames(string fatherDir, bool foreachNode, PickupFolderType folder) { List <string> outputDirNames = new List <string>(); logHelp.OriginDir = fatherDir; logHelp.OutputDirInLog(fatherDir, foreachNode, folder, outputDirNames); LogHelperExtend.WriteDocument(ExeDir, DateTime.Now.ToString(CommonFormat.DateToHourIntFormat) + FileSuffix.Log, string.Join("\r\n", outputDirNames)); }
public void OutputDirInLog(string fatherDir, bool foreachNode, PickupFolderType folderType, List <string> outputDirNames) { // string originDir=fatherDir; DirectoryInfo di = new DirectoryInfo(fatherDir); DirectoryInfo[] nodes = di.GetDirectories(); //是否需要继续遍历子目录 foreach (var item in nodes) { string dir = item.FullName; string outName = item.Name;// justOutputFolderName ? item.Name : dir; switch (folderType) { case PickupFolderType.FolderName: outName = item.Name; break; case PickupFolderType.RelativeDir: //相对路径,需要剔除原始目录 outName = item.FullName; if (!string.IsNullOrEmpty(OriginDir)) { outName = outName.Replace(OriginDir, string.Empty); } break; case PickupFolderType.FullName: outName = item.FullName; break; default: break; } outputDirNames.Add(outName);//日志追加 //输出到日志 if (foreachNode) { OutputDirInLog(dir, foreachNode, folderType, outputDirNames); } } }