C#获取指定路径下的文件夹
string DirPath=Application.StartupPath; //指定一个路径,此处路径为应用程序默认路径
if (Directory.GetDirectories(DirPath).LongLength <= 0)
{
MessageBox.Show("Not found Directories!", "Error :", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
}
string[] folders = Directory.GetDirectories(DirPath);
string type = "";
foreach (string folder in folders)
{
type = folder.Replace(DirPath + "\\", "");
ComboBox1.Items.Add(type); //将文件夹名添加到ComboBox控件中
}