ASP.NET----获取当前计算机上所有的驱动器信息

本次代码主要为了演示获取当前计算机上的驱动信息:

本人计算机效果如下所示:

cs代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.BindGrid();
}

private void BindGrid()
{
//获取当前计算机上所有的驱动器信息
DriveInfo[] drivers = DriveInfo.GetDrives();

try
{
//数据绑定
this.GridView1.DataSource = drivers;
this.GridView1.DataBind();
}
catch
{

}
}
}

posted @ 2011-05-24 19:32  brainmao  阅读(338)  评论(0编辑  收藏  举报