Your Ads Here

Thursday, 8 March 2012

List the Computer’s Logical Drive using C#.NET


It shows how to list Computer’s Logical Drive using C#.NET
Keywords: C#.NET, C Sharp.NET, Drive, disc.

Import a namespace
1)      using System.IO;

Here the full Code to get logical drive list using C#.NET

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 testc
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (string drive in Directory.GetLogicalDrives())
            {
                lstDrives.Items.Add(drive);
            }
         
        }          
        }   
    }



No comments:

Post a Comment