6 March 2014

How to get drive list in c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window4.xaml
    /// </summary>
    public partial class Window4 : Window
    {
        public Window4()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgse)
        {
            DriveInfo[] strdrives = DriveInfo.GetDrives();
            foreach (DriveInfo strdrive in strdrives)
            {
                listBox1.Items.Add(strdrive);
            }
        }
    }
}
 
 
 

No comments:

Post a Comment