예제 #1
0
        private void StartTree()
        {
            try
            {
                // Set a default icon for the Computer.
                Icon iconForFile = SystemIcons.WinLogo;
                Invoke((MethodInvoker) delegate { driveImageList.Images.Add(iconForFile); });

                Log.Debug("Create the root node.");
                TreeNode tvwRoot = new TreeNode {
                    Text = Environment.MachineName, ImageIndex = 0
                };
                tvwRoot.SelectedImageIndex = tvwRoot.ImageIndex;
                BeginInvoke((MethodInvoker) delegate { driveTree.Nodes.Add(tvwRoot); });

                Log.Debug("Now we need to add any children to the root node.");
                foreach (Win32DiskDrive deviceInfo in Win32DiskDrive.Retrieve())
                {
                    try
                    {
                        Invoke((MethodInvoker) delegate { FillInStorageDeviceDirectoryType(tvwRoot, deviceInfo); });
                    }
                    catch (Exception ex)
                    {
                        Log.Warn(ex, "A storage device failed to enumerate.");
                    }
                }

                BeginInvoke((MethodInvoker) delegate { tvwRoot.Expand(); });
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, @"StartTree Threw:");
            }
        }
예제 #2
0
 public IActionResult Drives()
 {
     return(Json(Win32DiskDrive.Retrieve()));
 }