日期:2014-05-18 浏览次数:20747 次
private void SetReadOnly(string dirPath) { string[] dirPathes = Directory.GetDirectories(dirPath, "*.*", SearchOption.AllDirectories); string[] filePathes = Directory.GetFiles(dirPath, "*.*", SearchOption.AllDirectories); foreach (var dp in dirPathes) { DirectoryInfo dir = new DirectoryInfo(dirPath); dir.Attributes = FileAttributes.Normal & FileAttributes.Directory; } foreach (var fp in filePathes) { File.SetAttributes(fp, System.IO.FileAttributes.Normal); } }