我有一些代碼:僅在C#中列出子文件夾?
string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string pathDownload = Path.Combine(pathUser, @"documents\iracing\setups\");
DirectoryInfo dinfo = new DirectoryInfo(pathDownload); // Populates field with all Sub Folders
FileInfo[] Files = dinfo.GetFiles("*.sto");
foreach (FileInfo file in Files)
{
listBox2.Items.Add(file.Name);
}
我想要的子文件夾:要顯示documents\iracing\setups\
,而不是文件...包括.sto文件。我只需要列出子文件夾....我不知道該怎麼做?謝謝!
我該如何填充我的listbox2這些子文件夾? –
完美! Tahanks! –