is there a way that i can remove the property \"read only\"?
i tried this:
var di = new DirectoryInfo(\"C:\\\\Work\");
di.Attributes &
A better way of doing might be.
string cmd = string.Format(" /C ATTRIB -R \"{0}\\*.*\" /S /D", binPath);
CallCommandlineApp("cmd.exe", cmd);
private static bool CallCommandlineApp(string progPath, string arguments)
{
var info = new ProcessStartInfo()
{
UseShellExecute = false,
RedirectStandardOutput = true,
FileName = progPath,
Arguments = arguments
};
var proc = new Process()
{
StartInfo = info
};
proc.Start();
using (StreamReader stReader = proc.StandardOutput)
{
string output = stReader.ReadToEnd();
Console.WriteLine(output);
}
// TODO: Do something with standard error.
proc.WaitForExit();
return (proc.ExitCode == 0) ? true : false;
}
I ran into this samiliar problem of wanting to clear the read/write flag of a directory and any sub-files/directories it might have. And using a foreach loop sound like extra work, when the Attrib command line function works just fine and is almost instantaneous.