示例#1
0
        private ArrayList GetCDMediaSize()
        {
            ArrayList collection2 = new ArrayList();

            try
            {
                ManagementObjectCollection.ManagementObjectEnumerator enumerator = null;
                SelectQuery query = new SelectQuery("Win32_CDROMDrive");
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
                try
                {
                    enumerator = searcher.Get().GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        ManagementObject info = (ManagementObject)enumerator.Current;
                        if (info["Size"] != null)
                        {
                            collection2.Add(GeneralModule.FormatBytes(double.Parse(info["Size"].ToString())));
                        }
                        else
                        {
                            collection2.Add("Blank or No Media");
                        }
                    }
                    return(collection2);
                }
                finally
                {
                    if (enumerator != null)
                    {
                        enumerator.Dispose();
                    }
                }
            }
            catch
            {
                collection2 = null;
            }
            return(collection2);
        }
示例#2
0
        private void ScanFiles(string filepath)
        {
            if (filepath.Trim().Length > 0)
            {
                try
                {
                    string[] filecollect = Directory.GetFileSystemEntries(filepath);
                    foreach (string file in filecollect)
                    {
                        if (Directory.Exists(file))
                        {
                            if (lvScanResult.Items.Count < 25)
                            {
                                ScanFiles(file);
                            }
                            else
                            {
                                try
                                {
                                    if (search_thread != null)
                                    {
                                        if (search_thread.ThreadState == ThreadState.Suspended || search_thread.ThreadState == ThreadState.Running)
                                        {
                                            search_thread.Resume();
                                            while (search_thread.ThreadState != ThreadState.Running)
                                            {
                                            }
                                        }
                                        search_thread.Abort();
                                        search_thread.Join();
                                        search_thread = null;
                                    }
                                }
                                catch
                                {
                                    search_thread     = null;
                                    lab_showfile.Text = scanningDisk + " 50个大文件扫描完成,请点击右键定位文件---------------------------------->>>>>>>";
                                }
                            }
                        }
                        else
                        {
                            ListViewItem item;
                            lab_showfile.Text = "正在扫描:" + file;
                            System.IO.FileInfo f = new System.IO.FileInfo(file);
                            if (f.Length >= 20971520)
                            {
                                item = new ListViewItem(f.Name);

                                int j = imageList2.Images.Count;
                                ApiGetICON.GetIcon(file, imageList2);
                                item.ImageIndex = j;

                                item.SubItems.Add(GeneralModule.FormatBytes(double.Parse(f.Length.ToString())));
                                item.SubItems.Add(file);
                                lvScanResult.Items.Add(item);
                            }
                        }
                    }
                }
                catch
                {
                    //MessageBox.Show("扫描已经完成");
                }
            }
        }
示例#3
0
 private void diskInfo(string diskFlag)
 {
     label5.Text = "正在统计磁盘信息...";
     try
     {
         WMIDrives wmiDrives = new WMIDrives();
         int       num2;
         if (wmiDrives.VolumeLetter != null)
         {
             int num4 = wmiDrives.VolumeLetter.Count - 1;
             for (num2 = 0; num2 <= num4; num2++)
             {
                 if (wmiDrives.VolumeLetter[num2].ToString() == diskFlag)
                 {
                     label5.Text = wmiDrives.VolumeLetter[num2].ToString().Substring(0, 1) + "盘空间总计: " + GeneralModule.FormatBytes(double.Parse(wmiDrives.VolumeTotalSize[num2].ToString())) + " (已用 " + GeneralModule.FormatBytes(double.Parse(wmiDrives.VolumeUsedSpace[num2].ToString())) + ",剩余 " + GeneralModule.FormatBytes(double.Parse(wmiDrives.VolumeFreeSpace[num2].ToString())) + " ) 建议马上扫描";
                 }
             }
         }
     }
     catch
     {
         label5.Text = "磁盘信息读取出错!";
         return;
     }
 }