2 回答
TA贡献1951条经验 获得超3个赞
要包含所有文件和子目录,请new Files("@"C:\Temp\MyProductFiles\*.*")使用new DirFiles(@"C:\Temp\MyProductFiles\*.*".
var project =
new Project("MyProduct",
new Dir(@"%ProgramFiles%\My Company\My Product",
new Files(@"..\Release Folder\Release\*.*")
TA贡献1821条经验 获得超6个赞
据我所知,没有内置的机制来获取所有子目录,但您可以递归地遍历树,并将每个条目投影到DirFiles
IEnumerable<string> GetSubdirectories(string root)
{
string[] subdirectories = Directory.GetDirectories(root);
foreach (var subdirectory in subdirectories)
{
yield return subdirectory;
foreach (var nestedDirectory in GetSubdirectories(subdirectory))
{
yield return nestedDirectory;
}
}
}
DirFiles投影可以输出到带有强制通配符模式的数组中:
DirFiles[] dirFiles = GetSubdirectories(rootPath).Select(d => new DirFiles(Path.Combine(d, "*.*"))).ToArray();
然后,只需通过它即可:
var project = new Project("MyProduct", new Dir(@"C:\Temp\MyProduct", dirFiles)));
- 2 回答
- 0 关注
- 97 浏览
添加回答
举报