我已经设法从“根”文件夹子目录中获取文件,但我也从这些子目录目录中获取文件,这是我不想要的。
例子:RootDirectory>Subdirectories (wanted files)>directories2 (unwanted files)
我用过这段代码:
public void ReadDirectoryContent()
{
var s1 = Directory.GetFiles(RootDirectory, "*", SearchOption.AllDirectories);
{
for (int i = 0; i <= s1.Length - 1; i++)
FileInfo f = new FileInfo(s1[i]);
. . . etc
}
}