Example #1
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;
     }
 }
Example #2
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;
     }
 }
Example #3
0
        private void initialDiskRead()
        {
            try
            {
                WMIDrives wmiDrives = new WMIDrives();
                int       num2;
                this.tsLocalVolumes.Items.Clear();
                if (wmiDrives.VolumeLetter != null)
                {
                    int num4 = wmiDrives.VolumeLetter.Count - 1;
                    for (num2 = 0; num2 <= num4; num2++)
                    {
                        if (wmiDrives.VolumeFileSystem != null)
                        {
                            if (wmiDrives.VolumeFileSystem[num2].ToString() == "NTFS")
                            {
                                if (wmiDrives.VolumeLabel[num2].ToString() == "")
                                {
                                    ToolStripButton item = tsLocalVolumes.Items.Add("button1") as ToolStripButton;

                                    item.AutoSize = false;
                                    item.Size     = new Size(190, 35);

                                    item.Image      = imageList1.Images[1];
                                    item.ImageAlign = ContentAlignment.MiddleLeft;

                                    item.Text      = "(" + wmiDrives.VolumeLetter[num2].ToString().Substring(0, 2) + ")" + "系统盘";
                                    item.TextAlign = ContentAlignment.MiddleLeft;

                                    tsLocalVolumes.Items[tsLocalVolumes.Items.Count - 1].Click += new EventHandler(show);
                                }
                                else
                                {
                                    ToolStripButton item = tsLocalVolumes.Items.Add("button1") as ToolStripButton;

                                    item.AutoSize = false;
                                    item.Size     = new Size(190, 35);

                                    item.Image      = imageList1.Images[0];
                                    item.ImageAlign = ContentAlignment.MiddleLeft;

                                    item.Text      = "(" + wmiDrives.VolumeLetter[num2].ToString().Substring(0, 2) + ")" + wmiDrives.VolumeLabel[num2].ToString();
                                    item.TextAlign = ContentAlignment.MiddleLeft;

                                    tsLocalVolumes.Items[tsLocalVolumes.Items.Count - 1].Click += new EventHandler(show);
                                }
                            }
                            else
                            {
                                if (wmiDrives.VolumeFileSystem[num2].ToString() == "FAT32")
                                {
                                    ToolStripButton item = tsDriver.Items.Add("button1") as ToolStripButton;

                                    item.AutoSize = false;
                                    item.Size     = new Size(190, 35);

                                    item.Image      = imageList1.Images[0];
                                    item.ImageAlign = ContentAlignment.MiddleLeft;

                                    item.Text      = "(" + wmiDrives.VolumeLetter[num2].ToString().Substring(0, 2) + ")" + wmiDrives.VolumeLabel[num2].ToString();
                                    item.TextAlign = ContentAlignment.MiddleLeft;

                                    tsDriver.Items[tsDriver.Items.Count - 1].Click += new EventHandler(show);
                                }
                            }
                        }
                        else
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #4
0
        private void initialDiskRead()
        {
            try
            {
                WMIDrives wmiDrives = new WMIDrives();
                int num2 ;
                this.tsLocalVolumes.Items.Clear();
                if (wmiDrives.VolumeLetter != null)
                {
                    int num4 = wmiDrives.VolumeLetter.Count - 1;
                    for (num2 = 0; num2 <= num4; num2++)
                    {
                        if (wmiDrives.VolumeFileSystem != null)
                        {
                            if (wmiDrives.VolumeFileSystem[num2].ToString() == "NTFS")
                            {
                                if (wmiDrives.VolumeLabel[num2].ToString() == "")
                                {
                                    ToolStripButton item = tsLocalVolumes.Items.Add("button1") as ToolStripButton;

                                    item.AutoSize = false;
                                    item.Size = new Size(190, 35);

                                    item.Image = imageList1.Images[1];
                                    item.ImageAlign = ContentAlignment.MiddleLeft;

                                    item.Text = "(" + wmiDrives.VolumeLetter[num2].ToString().Substring(0, 2) + ")" + "系统盘";
                                    item.TextAlign = ContentAlignment.MiddleLeft;

                                    tsLocalVolumes.Items[tsLocalVolumes.Items.Count - 1].Click += new EventHandler(show);
                                }
                                else
                                {

                                    ToolStripButton item = tsLocalVolumes.Items.Add("button1") as ToolStripButton;

                                    item.AutoSize = false;
                                    item.Size = new Size(190, 35);

                                    item.Image = imageList1.Images[0];
                                    item.ImageAlign = ContentAlignment.MiddleLeft;

                                    item.Text = "(" + wmiDrives.VolumeLetter[num2].ToString().Substring(0, 2) + ")" + wmiDrives.VolumeLabel[num2].ToString();
                                    item.TextAlign = ContentAlignment.MiddleLeft;

                                    tsLocalVolumes.Items[tsLocalVolumes.Items.Count - 1].Click += new EventHandler(show);
                                }
                            }
                            else
                            {
                                if (wmiDrives.VolumeFileSystem[num2].ToString() == "FAT32")
                                {
                                    ToolStripButton item = tsDriver.Items.Add("button1") as ToolStripButton;

                                    item.AutoSize = false;
                                    item.Size = new Size(190, 35);

                                    item.Image = imageList1.Images[0];
                                    item.ImageAlign = ContentAlignment.MiddleLeft;

                                    item.Text = "(" + wmiDrives.VolumeLetter[num2].ToString().Substring(0, 2) + ")" + wmiDrives.VolumeLabel[num2].ToString();
                                    item.TextAlign = ContentAlignment.MiddleLeft;

                                    tsDriver.Items[tsDriver.Items.Count - 1].Click += new EventHandler(show);
                                }
                            }
                        }
                        else
                        {
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }