title: C# How to change FileAttributes from Normal to Directory
body: <p>A friend of mine gave me a corrupted SD Card which shows the "DCIM" folder as file. 
  I wrote a Console program to show me FileInfo, and it returns "Normal". Now I tried to change the FileAttributes from "Normal" to "Directory" like in the sample: <a href="http://msdn.microsoft.com/de-de/library/system.io.file.setattributes%28v=vs.110%29.aspx" rel="nofollow">http://msdn.microsoft.com/de-de/library/system.io.file.setattributes%28v=vs.110%29.aspx</a></p>
  
  <pre><code>static void Main(string[] args)
      {
          var path = "O://DCIM";
          FileAttributes attributes = File.GetAttributes(path);
          attributes = RemoveAttribute(attributes, FileAttributes.Normal);
          var attr = attributes | FileAttributes.Directory;
          File.SetAttributes(path, attr);
  
          var fi = new FileInfo(path);
          Console.WriteLine(fi.Name + " -- " + fi.Attributes);
          Console.ReadKey();
      }
  
      private static FileAttributes RemoveAttribute(FileAttributes attributes, FileAttributes attributesToRemove)
      {
          return attributes &amp; ~attributesToRemove;
      }
  </code></pre>
  
  <p>The program runs as expected, when I check attr before it is assigned it returns "Directory". But in the end, FileAttributes are still "Normal". </p>
  
  <p>Is it possible to change FileAttributes this way?
  Is there another solution to do this?  </p>