public void RemoveReadOnlyFlag(DirectoryInfo di) { if (ShellObject.CheckReadOnly(di.Attributes)) { di.Attributes = FileAttributes.Normal; readOnlyPaths.Add(di.FullName); } foreach (DirectoryInfo dif in di.GetDirectories()) { try { RemoveReadOnlyFlag(dif); } catch { } } foreach (FileInfo fi in di.GetFiles()) { if (ShellObject.CheckReadOnly(fi.Attributes)) { fi.Attributes = FileAttributes.Normal; readOnlyPaths.Add(fi.FullName); } } }