set folder read only to false
Currently my code to set the folder read only to false.
var di = new DirectoryInfo("C:\\NightlyBuild");
foreach (var file in di.GetFiles("*", SearchOption.AllDirectories))
file.Attributes &= ~FileAttributes.ReadOnly;
However, I did this to find the file in smallest file by sorting them in decesending order:
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=>x).Skip(int.Parse(args[0])))
Console.WriteLine(file);
foreach(var file in files.OrderByDescending(x=>x).Skip(int.Parse(args[0])))
Directory.Delete(file, true);
Any way to alter this code so that whatever file that i delete?
I just开发者_如何学Go want to set that file read-only to false? This file is actually a folder fyiTry
File.SetAttributes("C:\\NightlyBuild", FileAttributes.ReadOnly);
精彩评论