Beispiel #1
0
        /// <summary>
        /// get the list of logical drives on computer
        /// </summary>
        void GetDriveInfo()
        {
            try
            {
                DriveInfo[] drives = null;
                try
                {
                    drives = DriveInfo.GetDrives();
                }
                catch (IOException ex)
                {
                }
                catch (UnauthorizedAccessException ex)
                {
                }

                if (drives != null)
                {
                    foreach (DriveInfo drive in drives)
                    {
                        try
                        {
                            if ((drive.DriveType == DriveType.Fixed || drive.DriveType == DriveType.Removable) && drive.IsReady)
                            {
                                DriveData d = new DriveData(drive);
                                DriveData.Add(d);
                            }
                        }
                        catch
                        {
                        }
                    }
                    dgDrives.ItemsSource = DriveData;
                }
            }
            catch (Exception ex)
            {
                // ToDo: send exception details via SmartAssembly bug reporting!
            }
        }
Beispiel #2
0
        /// <summary>
        /// get the list of logical drives on computer
        /// </summary>
        void GetDriveInfo()
        {
            LogClass.AddInfoToLog(LogClass.LogInfo.Start, "GetDriveInfo");

            try
            {
                DriveInfo[] drives = null;

                try
                {
                    drives = DriveInfo.GetDrives();
                }
                catch (IOException ex)
                {
                    LogClass.AddErrorToLog(" Method - GetDriveInfo - Exeption [" + ex.GetType().Name + "] - " + ex.Message);
                }
                catch (UnauthorizedAccessException ex)
                {
                    LogClass.AddErrorToLog(" Method - GetDriveInfo - Exeption [" + ex.GetType().Name + "] - " + ex.Message);
                }

                if (drives != null)
                {
                    foreach (DriveInfo drive in drives)
                    {
                        try
                        {
                            if ((drive.DriveType == DriveType.Fixed || drive.DriveType == DriveType.Removable) && drive.IsReady)
                            {
                                var d = new DriveData(drive);
                                DriveData.Add(d);
                            }
                        }
                        catch (Exception ex)
                        {
                            LogClass.AddErrorToLog(" Method - GetDriveInfo - Exeption [" + ex.GetType().Name + "] - " + ex.Message);
                        }
                    }
                   // dgDrives.ItemsSource = DriveData;
                }
            }
            catch (Exception ex)
            {
                LogClass.AddErrorToLog(" Method - GetDriveInfo - Exeption [" + ex.GetType().Name + "] - " + ex.Message);
                // ToDo: send exception details via SmartAssembly bug reporting!
            }

            LogClass.AddInfoToLog(LogClass.LogInfo.End, "GetDriveInfo");
        }