Example #1
0
 public static void CleanDirectory(string directoryName, bool deleteTopDirectoryOnError)
 {
     if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(directoryName))
     {
         return;
     }
     string[] files = Directory.GetFiles(directoryName);
     for (int i = 0; i < (int)files.Length; i++)
     {
         string str = files[i];
         try
         {
             File.SetAttributes(str, FileAttributes.Normal);
             File.Delete(str);
         }
         catch (IOException oException)
         {
             deleteTopDirectoryOnError = false;
             break;
         }
     }
     string[] directories = Directory.GetDirectories(directoryName);
     for (int j = 0; j < (int)directories.Length; j++)
     {
         ProjectPathHelper.CleanDirectory(directories[j], deleteTopDirectoryOnError);
     }
     if (deleteTopDirectoryOnError)
     {
         Directory.Delete(directoryName, true);
     }
 }
Example #2
0
 public void Clean()
 {
     try
     {
         ProjectPathHelper.CleanDirectory(this.location, true);
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         if (!(exception is ArgumentException) && !(exception is IOException) && !(exception is NotSupportedException) && !(exception is UnauthorizedAccessException))
         {
             throw;
         }
     }
 }