//Microsoft Public License (Ms-PL)
//http://visualizer.codeplex.com/license
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
namespace Redwerb.BizArk.Core.Util
{
///
/// Provides methods that are useful when working with files and directories.
///
public static class FileUtil
{
///
/// Removes a directory as best as it can. Errors are ignored.
///
///
public static void RemoveDirectory(string dirPath)
{
foreach (string childDirPath in Directory.GetDirectories(dirPath))
RemoveDirectory(childDirPath);
foreach (string filePath in Directory.GetFiles(dirPath))
{
try
{
File.Delete(filePath);
}
catch (Exception ex)
{
Debug.WriteLine("Unable to delete " + filePath + ": " + ex.Message);
}
}
try
{
Directory.Delete(dirPath);
}
catch (Exception ex)
{
Debug.WriteLine("Unable to delete " + dirPath + ": " + ex.Message);
}
}
}
}