using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace xianshi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
DriveInfo[] di = DriveInfo.GetDrives();
foreach (DriveInfo d in di) {
comboBox1.Items.Add(d.Name);
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
treeView1.Nodes.Clear();
foreach (string str in Directory.GetDirectories(comboBox1.Text)) {
TreeNode node = new TreeNode();
node.Text = str;
treeView1.Nodes.Add(node);
}
}
}
}
转载于:https://my.oschina.net/u/2538590/blog/537461