Saturday, 14 July 2012

system information


If you want to system information (window or web application) than you can try this code.

This is front end coding in c#.

using System.IO;

public partial class _Default : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SystemInfo();
        }
    }
    public void SystemInfo()
    {
       
        string[] s = Environment.GetLogicalDrives();
        foreach (string item in s)
        {
            DropDownList1.Items.Add(new ListItem(item));
        }
    }
   
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList2.Items.Clear();
        DirectoryInfo d = new DirectoryInfo(DropDownList1.SelectedItem.Text);
        DirectoryInfo[] da = d.GetDirectories();
        foreach (DirectoryInfo item in da)
        {
            DropDownList2.Items.Add(new ListItem(item.Name));
        }
    }
}


for aspx page you can take two dropdownlist .

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home