我正在编写一个脚本来从我的构建中生成一些人工制品,所以我想先清理不需要的文件。我正在使用CleanDirectory(dirPath, predicate)
.
我发现找出文件的目录非常困难。如果我使用GetDirectoryName()
它似乎只是让我得到直接的父级,而不是完整的目录路径。
Func<IFileSystemInfo, bool> predicate =
fileSystemInfo => {
// Dont filter out any directories
if (fileSystemInfo is IDirectory)
return false;
var path = fileSystemInfo.Path.FullPath;
var directory = ((DirectoryPath)path).GetDirectoryName();
...
}
显然,我可以使用 .NET FrameworkSystem.IO
类轻松地做到这一点,但随后我得到带有斜线方向错误的字符串,并且事情不能与使用 POSIX 路径的 Cake 顺利互操作。