コード例 #1
0
        private void Unprotect()
        {
            DriveInfo di = cbDrives.SelectedItem as DriveInfo;

            if (di == null)
            {
                return;
            }
            Windows7Taskbar.SetProgressState(Handle, ProgressState.Indeterminate);
            MainButton.Text = "Close";
            action          = ButtonAction.Close;
            try
            {
                string[] files = Directory.GetFiles(di.RootDirectory.FullName, "dummy.file*");
                foreach (string file in files)
                {
                    File.Delete(file);
                }
                long free = di.TotalFreeSpace;
                InfoLabel.Text = String.Format("{0} dummy file(s) deleted, {1} free", files.Length, GetSize(free));
            }
            catch (Exception ex)
            {
                InfoLabel.Text = ex.Message;
            }
            Windows7Taskbar.SetProgressState(Handle, ProgressState.NoProgress);
        }
コード例 #2
0
        private void Protect()
        {
            DriveInfo di = cbDrives.SelectedItem as DriveInfo;

            if (di == null)
            {
                return;
            }
            Windows7Taskbar.SetProgressState(Handle, ProgressState.Indeterminate);
            MainButton.Text = "Close";
            action          = ButtonAction.Close;
            try
            {
                MainButton.Enabled = false;
                MainButton.Update();
                long cnt  = 0;
                long size = di.TotalFreeSpace;
                while (size > 0)
                {
                    cnt++;
                    FileInfo fi = new FileInfo((di.RootDirectory.FullName + "dummy.file" + (cnt > 1 ? cnt.ToString() : "")));
                    using (FileStream fs = fi.OpenWrite())
                    {
                        InfoLabel.Text = String.Format("Writing {0} {1} remaining", fi.Name, GetSize(size));
                        InfoLabel.Update();
                        long newSize = Math.Min(fs.Length + size, 4294967294);
                        fs.SetLength(newSize);
                    }
                    size = di.TotalFreeSpace;
                }
                InfoLabel.Text = String.Format("{0} dummy file(s) created, {1} free", cnt, GetSize(di.TotalFreeSpace));
            }
            catch (Exception ex)
            {
                InfoLabel.Text = ex.Message;
            }
            MainButton.Enabled = true;
            Windows7Taskbar.SetProgressState(Handle, ProgressState.NoProgress);
        }
コード例 #3
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     Windows7Taskbar.SetProgressState(Handle, ProgressState.NoProgress);
     LoadList(Directory.GetDirectoryRoot("."));
 }