set folder read only to false
<p>Currently my code to set the folder read only to <strong>false</strong>.</p>

<pre><code>var di = new DirectoryInfo("C:\\NightlyBuild");
            foreach (var file in di.GetFiles("*", SearchOption.AllDirectories))
                file.Attributes &amp;= ~FileAttributes.ReadOnly;
</code></pre>

<p>However, I did this to find the file in smallest file by sorting them in decesending order:</p>

<pre><code>string path = "C:\\NightlyBuild\\";
var files = Directory.GetDirectories(path, "NightlyBuild.*");
            foreach(var file in files)
            Console.WriteLine(file);
            foreach(var file in files.OrderByDescending(x=&gt;x).Skip(int.Parse(args[0])))
            Console.WriteLine(file);
            foreach(var file in files.OrderByDescending(x=&gt;x).Skip(int.Parse(args[0])))
            Directory.Delete(file, true);
</code></pre>

<p>Any way to alter this code so that whatever file that i delete?<br>
I just want to set that file read-only to false? This file is actually a folder fyi</p>
