Ejemplo n.º 1
0
        private void CarregarINFOdisco()
        {
            if (Directory.Exists("E:\\Rascal"))
            {
                //Nome
                labelDiscoNome.Text = "External Insys";

                foreach (var drive in DriveInfo.GetDrives())
                {
                    if (Directory.Exists(drive.Name.Split(':')[0] + ":\\Rascal"))
                    {
                        //Diretorio
                        labelDiscoDiretorio.Text = drive.Name.Split(':')[0];

                        //Tipo
                        labelDiscoTipo.Text = drive.DriveFormat.ToUpper();

                        //Espaço Total
                        double totalSpace = drive.TotalSize;
                        totalSpace            = (totalSpace / Math.Pow(1024, 3));
                        labelDiscoETotal.Text = totalSpace.ToString("0.") + " GB";

                        //Espaço Rascal
                        double totalRascal = Funcionalidades.GetDirSize("E:\\Rascal");
                        totalRascal = (totalRascal / Math.Pow(1024, 3));

                        if (totalRascal.ToString("0.").Equals("0"))
                        {
                            totalRascal           = Funcionalidades.GetDirSize("E:\\Rascal");
                            totalRascal           = (totalRascal / Math.Pow(1024, 2));
                            labelDiscoRascal.Text = totalRascal.ToString("0.00") + " MB";
                        }
                        else
                        {
                            labelDiscoRascal.Text = totalRascal.ToString("0.00") + " GB";
                        }


                        //Espaço Livre
                        double freeSpace = drive.TotalFreeSpace;
                        freeSpace             = (freeSpace / Math.Pow(1024, 3));
                        labelDiscoELivre.Text = freeSpace.ToString("0.00") + " GB";
                        labelFreePercent.Text = (100 * (double)drive.TotalFreeSpace / drive.TotalSize).ToString("0.0") + "%";

                        //Espaço Ocupado
                        double usedsize = totalSpace - freeSpace;
                        labelDiscoEOcupado.Text = usedsize.ToString("0.00") + " GB";
                        labelUsedPercent.Text   = (100 * (double)(drive.TotalSize - drive.TotalFreeSpace) / drive.TotalSize).ToString("0.0") + "%";

                        break;
                    }
                }

                lockedData = false;
                _FormInicio.BloquearInteracoes(true);
            }
            else
            {
                //Nome
                labelDiscoNome.Text = "N/A";

                //Diretorio
                labelDiscoDiretorio.Text = "N/A";

                //Tipo
                labelDiscoTipo.Text = "";

                //Espaço Total
                labelDiscoETotal.Text = "N/A";

                //Espaço Rascal
                labelDiscoRascal.Text = "N/A";

                //Espaço Livre
                labelDiscoELivre.Text = "N/A";
                labelFreePercent.Text = "";

                //Espaço Ocupado
                labelDiscoEOcupado.Text = "N/A";
                labelUsedPercent.Text   = "";

                lockedData = true;
                _FormInicio.BloquearInteracoes(false);

                Thread _Thread = new Thread(new ThreadStart(VerificarConecao));
                _Thread.IsBackground = true;
                _Thread.Start();
            }
        }