private void cleanUpASPNETTempFilesToolStripMenuItem_Click(object sender, EventArgs e) { try { this.toolStripStatusLabel1.Text = "IIS sites stopping.."; IISHelper.StopActiveSites(); this.toolStripStatusLabel1.Text = "Cleaning Temporary ASP.NET Files.."; CleanupTempAspNetFiles("Framework\v2.0.50727"); CleanupTempAspNetFiles("Framework64\v2.0.50727"); CleanupTempAspNetFiles("Framework\v3.5"); CleanupTempAspNetFiles("Framework64\v3.5"); CleanupTempAspNetFiles("Framework\v4.0.30319"); CleanupTempAspNetFiles("Framework64\v4.0.30319"); this.toolStripStatusLabel1.Text = "Cleaning User's Temp folder.."; string tempfolder = Path.GetTempPath(); FileSystemUtils.CleanupDirectory(tempfolder, false); IISHelper.StartSites(); this.toolStripStatusLabel1.Text = "Temporary ASP.NET Files and Temp folder have been cleaned. IIS sites restarted"; } catch (UnauthorizedAccessException) { MessageBox.Show("To perform operation application must Run as Administrator"); } }
private void CleanupTempAspNetFiles(string FrameworkVersion) { this.toolStripStatusLabel1.Text = string.Format("Cleaning Temporary ASP.NET Files at '{0}'..", FrameworkVersion); FileSystemUtils.CleanupDirectory(string.Format(@"C:\WINDOWS\Microsoft.NET\{0}\Temporary ASP.NET Files\", FrameworkVersion), false); }