Example #1
0
        public void doClean(bool temp, bool reclbin, bool intertemp)
        {
            txtState.Text  = "Please Wait...";
            txtState.Text += "\n";
            if (temp)
            {
                string   tempfolder = System.IO.Path.GetTempPath();
                string[] folder     = Directory.GetDirectories(tempfolder);
                string[] files      = Directory.GetFiles(tempfolder);

                txtState.Text += "Starting deleting temp...\n";
                for (int i = 0; i < folder.Length; i++)
                {
                    try
                    {
                        Directory.Delete(folder[i], true);
                        txtState.Text += "Delete folder " + i.ToString() + "\n";
                        txtState.ScrollToEnd();
                    }
                    catch
                    {
                        txtState.Text += "Unable to delete folder " + i.ToString() + "\nTry to start the application as Admin\n";
                        txtState.ScrollToEnd();
                    }
                }
                for (int i = 0; i < files.Length; i++)
                {
                    try
                    {
                        File.Delete(files[i]);
                        txtState.Text += "Delete file " + i.ToString() + "\n";
                        txtState.ScrollToEnd();
                    }
                    catch
                    {
                        txtState.Text += "Unable to delete file " + i.ToString() + "\nTry to start the application as Admin\n";
                        txtState.ScrollToEnd();
                    }
                }
                txtState.Text += "Temp delete finished...\n";
                txtState.ScrollToEnd();
            }
            if (reclbin)
            {
                txtState.Text += "Starting Emptying Recycle Bin...\n";
                txtState.ScrollToEnd();
                EmptyBin.EmptyBin.SHEmptyRecycleBin(IntPtr.Zero, null, EmptyBin.EmptyBin.RecycleFlags.SHERB_NOCONFIRMATION);
                txtState.Text += "Emptying Recycle Bin finished...\n";
                txtState.ScrollToEnd();
            }
            if (intertemp)
            {
                txtState.Text += "Start Inet Temp Files...\n";
                txtState.ScrollToEnd();
                inetTemp it = new inetTemp();
                if (it.ShowDialog() == true)
                {
                    txtState.Text += "Delete Inet Temp Files finished...\n";
                    txtState.ScrollToEnd();
                }
            }
            if (doC1 || doC2 || doC3)
            {
                doCClean(doC1, doC2, doC3);
            }
            txtState.Text += "\nDisk Cleanup Finished at " + DateTime.Now.ToString();
            txtState.ScrollToEnd();
        }
Example #2
0
        public void doClean(bool temp, bool reclbin, bool intertemp)
        {
            txtState.Text = "Please Wait...";
            txtState.Text += "\n";
            if (temp)
            {
                string tempfolder = System.IO.Path.GetTempPath();
                string[] folder = Directory.GetDirectories(tempfolder);
                string[] files = Directory.GetFiles(tempfolder);

                txtState.Text += "Starting deleting temp...\n";
                for (int i = 0; i < folder.Length; i++)
                {
                    try
                    {
                        Directory.Delete(folder[i], true);
                        txtState.Text += "Delete folder " + i.ToString() + "\n";
                        txtState.ScrollToEnd();
                    }
                    catch
                    {
                        txtState.Text += "Unable to delete folder " + i.ToString() + "\nTry to start the application as Admin\n";
                        txtState.ScrollToEnd();
                    }
                }
                for (int i = 0; i < files.Length; i++)
                {
                    try
                    {
                        File.Delete(files[i]);
                        txtState.Text += "Delete file " + i.ToString() + "\n";
                        txtState.ScrollToEnd();
                    }
                    catch
                    {
                        txtState.Text += "Unable to delete file " + i.ToString() + "\nTry to start the application as Admin\n";
                        txtState.ScrollToEnd();
                    }
                }
                txtState.Text += "Temp delete finished...\n";
                txtState.ScrollToEnd();
            }
            if (reclbin)
            {
                txtState.Text += "Starting Emptying Recycle Bin...\n";
                txtState.ScrollToEnd();
                EmptyBin.EmptyBin.SHEmptyRecycleBin(IntPtr.Zero, null, EmptyBin.EmptyBin.RecycleFlags.SHERB_NOCONFIRMATION);
                txtState.Text += "Emptying Recycle Bin finished...\n";
                txtState.ScrollToEnd();
            }
            if (intertemp)
            {
                txtState.Text += "Start Inet Temp Files...\n";
                txtState.ScrollToEnd();
                inetTemp it = new inetTemp();
                if (it.ShowDialog() == true)
                {
                    txtState.Text += "Delete Inet Temp Files finished...\n";
                    txtState.ScrollToEnd();
                }
            }
            if (doC1 || doC2 || doC3)
            {
                doCClean(doC1, doC2, doC3);
            }
            txtState.Text += "\nDisk Cleanup Finished at " + DateTime.Now.ToString();
            txtState.ScrollToEnd();
        }