Posted By

sekihin on 09/01/11


Tagged

file c#


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

c


delete all files in a directory


 / Published in: C#
 

URL: http://stackoverflow.com/questions/611921/how-do-i-delete-a-directory-with-read-only-files-in-c

  1. private static void DeleteFileSystemInfo(FileSystemInfo fsi)
  2. {
  3. fsi.Attributes = FileAttributes.Normal;
  4. var di = fsi as DirectoryInfo;
  5.  
  6. if (di != null)
  7. {
  8. foreach (var dirInfo in di.GetFileSystemInfos())
  9. DeleteFileSystemInfo(dirInfo);
  10. }
  11.  
  12. fsi.Delete();
  13. }

Report this snippet  

You need to login to post a comment.