예제 #1
0
        private void DriveComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            LogicalDrive chosenLogicalDrive = logicalDrives[DriveComboBox.SelectedIndex];

            subThread = new Thread(() => getLogicalDriveSubDirectories(chosenLogicalDrive));
            subThread.Start();
        }
예제 #2
0
        public void getLogicalDriveSubDirectories(LogicalDrive chosenLogicalDrive)
        {
            Thread t = new Thread(chosenLogicalDrive.GetDirectories);

            chosenLogicalDrive.SubDirectoriesDiscoveredEvent -= onLogicalDriverSubDirectoriesDiscovered;
            chosenLogicalDrive.SubDirectoriesDiscoveredEvent += onLogicalDriverSubDirectoriesDiscovered;

            t.Start();
            t.Join();
        }
예제 #3
0
        // Обработчик события получения списка папок на устройстве
        public void onLogicalDriverSubDirectoriesDiscovered(LogicalDrive logicalDrive)
        {
            DirectoryListBox.BeginInvoke(new Action(() =>
            {
                DirectoryListBox.Items.Clear();

                foreach (Directory directory in logicalDrive.SubDirectories)
                {
                    DirectoryListBox.Items.Add(directory.DirName);
                }
            }));
        }
예제 #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Получаем названия (пути) подключенных устройств
            string[] logicalDrivesNames = Environment.GetLogicalDrives();
            logicalDrives = new LogicalDrive[logicalDrivesNames.Length];

            // Заполняем массив с устройствами
            for (int i = 0, numOfLogicalDrives = logicalDrivesNames.Length; i < numOfLogicalDrives; ++i)
            {
                logicalDrives[i] = new LogicalDrive(logicalDrivesNames[i]);
            }

            // Добавляем устройства в КомбоБокс
            DriveComboBox.Items.AddRange(logicalDrivesNames);
        }