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

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

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
{

}
}
}

相关文章:

  • 2021-06-27
  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
相关资源
相似解决方案