title: Access to the path is denied
body: <p>For my WPF application, I have to create folders with images files for eg: C:\Pearl\Src\TEMP. Later when those files are not needed, I am deleting the folders programmatically. But I get "Access to the path ' '  is denied". I also tried to assign access rights to the temporary folders created but not of much use.</p>
  
  <pre><code>using System.IO;
  
  var activeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
  
  var dInfo = Directory.GetParent(Path.GetDirectoryName(activeDir);
  
  var dSecurity = dInfo.GetAccessControl();
  
  dSecurity.AddAccessRule(new FileSystemAccessRule(@"ATSDEV\ABCD", FileSystemRights.DeleteSubdirectoriesAndFiles, AccessControlType.Allow));
  
  dInfo.SetAccessControl(dSecurity); // Set the new access settings.
  
  var ImageDir = Path.Combine(dInfo.ToString(), "TEMP");
  
  System.IO.Directory.CreateDirectory(ImageDir, dSecurity);
  </code></pre>