Tuesday, 1 November 2011

Remove files attributes of a directory in c#.net


using System.IO;


private void ClearAttributes(string currentDir)
{
if (Directory.Exists(currentDir))
      {
            string[] subDirs = Directory.GetDirectories(currentDir);
            foreach (string dir in subDirs)
                ClearAttributes(dir);

            string[] files = files = Directory.GetFiles(currentDir);
            foreach (string file in files)
                File.SetAttributes(file, FileAttributes.Normal);
      }
}

No comments:

Post a Comment