예제 #1
0
        private void buttonRefresh_Click(object sender, System.EventArgs e)
        {
            // Populate the list of drives
            this.listDrives.Items.Clear();

            string [] driveNames = System.IO.Directory.GetLogicalDrives();
            foreach (string driveName in driveNames)
            {
                System.IO.DirectoryInfo drive = new System.IO.DirectoryInfo(driveName);
                if (drive.Exists)
                {
                    DriveInfo driveInfo = new DriveInfo(driveName[0]);
                    if (driveInfo.DriveType == DriveInfo.DriveTypeEnum.LocalDisk)
                    {
                        string status = driveName + " " +
                                        DriveInfo.GetFriendlyBytes(driveInfo.FreeSpace) + " of " +
                                        DriveInfo.GetFriendlyBytes(driveInfo.Size) + " free";
                        ZeroFile zf = new ZeroFile(driveName[0]);
                        if (zf.Exists)
                        {
                            status += " with " + DriveInfo.GetFriendlyBytes(zf.Size) + " zeroed";
                        }
                        this.listDrives.Items.Add(status);
                    }
                }
            }
        }
예제 #2
0
        private void buttonExpand_Click(object sender, System.EventArgs e)
        {
            int      selectedDrive = listDrives.SelectedIndex;
            char     driveLetter   = listDrives.SelectedItem.ToString()[0];
            ZeroFile zf            = new ZeroFile(driveLetter);

            if (!zf.Exists)
            {
                MessageBox.Show("This drive does not have a Zeroer File", "Error");
            }
            else
            {
                GetAmountForm form = new GetAmountForm();
                form.Text   = "Expand Zeroer File by...";
                form.Amount = 1;
                form.Units  = "GigaBytes";
                if (form.ShowDialog() != DialogResult.Cancel)
                {
                    this.Refresh();
                    long amount = form.Amount;
                    if (form.Units == "KiloBytes")
                    {
                        amount *= DriveInfo.KILOBYTE;
                    }
                    else if (form.Units == "MegaBytes")
                    {
                        amount *= DriveInfo.MEGABYTE;
                    }
                    else if (form.Units == "GigaBytes")
                    {
                        amount *= DriveInfo.GIGABYTE;
                    }
                    this.Cursor = Cursors.WaitCursor;
                    this.buttonCreate.Enabled        = false;
                    this.buttonRemove.Enabled        = false;
                    this.buttonExpand.Enabled        = false;
                    this.buttonShrink.Enabled        = false;
                    this.buttonZeroFreeSpace.Enabled = false;
                    zeroFile = new ZeroFile(driveLetter);
                    zeroFile.Expand(amount / DriveInfo.MEGABYTE, chkWithOnes.Checked, this.progressBar);
                    zeroFile = null;
                    buttonRefresh_Click(sender, e);
                    listDrives.SelectedIndex = selectedDrive;
                    this.Cursor = Cursors.Arrow;
                }
            }
        }
예제 #3
0
        private void buttonZeroFreeSpace_Click(object sender, EventArgs e)
        {
            int      selectedDrive = listDrives.SelectedIndex;
            char     driveLetter   = listDrives.SelectedItem.ToString()[0];
            ZeroFile zf            = new ZeroFile(driveLetter);

            this.Cursor = Cursors.WaitCursor;
            this.buttonCreate.Enabled        = false;
            this.buttonRemove.Enabled        = false;
            this.buttonExpand.Enabled        = false;
            this.buttonShrink.Enabled        = false;
            this.buttonZeroFreeSpace.Enabled = false;
            zeroFile = new ZeroFile(driveLetter);
            zeroFile.ZeroFreeSpace(chkWithOnes.Checked, this.progressBar);
            zeroFile = null;
            buttonRefresh_Click(sender, e);
            listDrives.SelectedIndex = selectedDrive;
            this.Cursor = Cursors.Arrow;
        }
예제 #4
0
        private void listDrives_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            char     driveLetter = listDrives.SelectedItem.ToString()[0];
            ZeroFile zf          = new ZeroFile(driveLetter);

            if (zf.Exists)
            {
                this.buttonCreate.Enabled        = false;
                this.buttonRemove.Enabled        = true;
                this.buttonExpand.Enabled        = true;
                this.buttonShrink.Enabled        = true;
                this.buttonZeroFreeSpace.Enabled = true;
            }
            else
            {
                this.buttonCreate.Enabled        = true;
                this.buttonRemove.Enabled        = false;
                this.buttonExpand.Enabled        = false;
                this.buttonShrink.Enabled        = false;
                this.buttonZeroFreeSpace.Enabled = true;
            }
        }
예제 #5
0
        private void buttonRemove_Click(object sender, System.EventArgs e)
        {
            int      selectedDrive = listDrives.SelectedIndex;
            char     driveLetter   = listDrives.SelectedItem.ToString()[0];
            ZeroFile zf            = new ZeroFile(driveLetter);

            if (!zf.Exists)
            {
                MessageBox.Show("This drive does not have a Zeroer File", "Error");
            }
            else
            {
                this.Cursor = Cursors.WaitCursor;
                this.buttonCreate.Enabled        = false;
                this.buttonRemove.Enabled        = false;
                this.buttonExpand.Enabled        = false;
                this.buttonShrink.Enabled        = false;
                this.buttonZeroFreeSpace.Enabled = false;
                zf.Delete();
                buttonRefresh_Click(sender, e);
                listDrives.SelectedIndex = selectedDrive;
                this.Cursor = Cursors.Arrow;
            }
        }
예제 #6
0
        public long GetSize(char DriveLetter)
        {
            ZeroFile zf = new ZeroFile(DriveLetter);

            return(zf.Size);
        }