/// <summary>
/// 窗体加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void InvoiceDownload_Load(object sender, EventArgs e)
{
this.Text += " 版本:" + Application.ProductVersion;//为窗体设置一个标题
SelectQuery selectQuery = new SelectQuery("select * from win32_logicaldisk");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(selectQuery);
var drivers = searcher.Get();
List<string> disks = new List<string>();//盘符列表
foreach (var driver in drivers) //遍历路径
{
string name = driver["Name"].ToString();
disks.Add(name);
CbDisk.Items.Add(name);//获取所有盘符并添加到界面的Combox中
}
CbDisk.SelectedIndex = 1;//指定到所有盘符的第二个盘符
}