当前位置:编程学习 > C#/ASP.NET >>

VB2010 关于驱动器

请教高手:

   VB2010有驱动器控件吗,如何在窗体上设置驱动器!!!

--------------------编程问答-------------------- 添加ComboBox 控件。然后直接复制下面的代码。
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
         Dim drives As System.IO.DriveInfo() = System.IO.DriveInfo.GetDrives()
         For Each CiPan As System.IO.DriveInfo In drives
             ComboBox1.Items.Add(CiPan.Name)
         Next
         ComboBox1.SelectedIndex = 0
 
    End Sub
--------------------编程问答-------------------- 放一个listbox
private void Form1_Load(object sender, EventArgs e)
        {
            DriveInfo[] di = DriveInfo.GetDrives();
            foreach (DriveInfo itemDrive in di)
            {
                listBox1.Items.Add(itemDrive.Name);
            }
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DriveInfo di = new DriveInfo(listBox1.SelectedIndex.ToString());

            MessageBox.Show("Available Free Space:"+di.AvailableFreeSpace+"/n"+
                "Driver Format:"+di.DriveFormat+"/n"+
                "Driver Type:"+di.DriveType+"/n"+
                "Is Ready:"+di.IsReady.ToString()+"/n"+
                "Name:"+di.Name+"/n"+
                "Root Directory:"+di.RootDirectory+"/n"+
                "ToString() Value:"+di.ToString()+"/n"+
                "Total Free Space:"+di.TotalFreeSpace+"/n"+
                "Volume Lable:"+di.VolumeLabel.ToString(),di.Name+"DRIVER INFO" );
        }

http://www.cnblogs.com/zhwx/archive/2012/02/19/2358318.html参考 --------------------编程问答--------------------
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,