DirectoryInfo d = new DirectoryInfo(path);
if() // there is a file in the directory do something.
如果存在任何文件,我可以获取文件,但我还必须考虑该子文件夹路径中没有文件的可能性。
答案 0 :(得分:3)
<div class="row">
<div class="col-sm-4">
<div class="row"></div>
<div class="row"></div>
<div class="row"></div>
</div>
<div class="col-sm-4 scroll-column">
<div class="row"></div>
<div class="row"></div>
<div class="row"></div>
</div>
<div class="col-sm-4">
<div class="row"></div>
<div class="row"></div>
<div class="row"></div>
</div>
</div>
.scroll-column {
whitespace: no-wrap;
overflow-x: auto;
}
使用string[] files = System.IO.Directory.GetFiles(path);
if (files.Length == 0)
Console.WriteLine("Empty");
else
Console.WriteLine("Not Empty");
EnumerateFiles
答案 1 :(得分:0)
如果没有文件,以下内容将返回一个空字符串数组:
var files = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly);
答案 2 :(得分:0)