public Boolean CleanRecentData() { isAllClean = true; String SysRecentPath = System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\Recent"; DirectoryInfo SysRecDir = new DirectoryInfo(SysRecentPath); File.SetAttributes(SysRecentPath, FileAttributes.Normal); foreach (FileInfo fi in SysRecDir.GetFiles()) //Access Denied //Exception is thrown here { try { fi.Delete(); } catch (Exception ex) { recentLogLines.AppendLine(ex.Message); isAllClean = false; } } foreach (DirectoryInfo dir in SysRecDir.GetDirectories()) { try { dir.Delete(true); } catch (Exception ex) { recentLogLines.AppendLine(ex.Message); isAllClean = false; } } return isAllClean; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)