using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
using System.Windows.Forms;

namespace Support_pedagogique_numerique
{
	/// <summary>
	/// Description résumée de Class1.
	/// </summary>
	class Purge
	{
		static public void DirPurge(string targetDirectory, string extension)
		{
			try 
			{
				string [] fileEntries = System.IO.Directory.GetFiles(targetDirectory);
				foreach(string fileName in fileEntries)
				{
					if( fileName.EndsWith(extension) ) {
						File.Delete(fileName);
					}
				}

				string [] subdirectoryEntries = System.IO.Directory.GetDirectories(targetDirectory);
				foreach(string subdirectory in subdirectoryEntries)
				{
					DirPurge(subdirectory, extension);
				}
			} 
			catch(Exception e) 
			{
				MessageBox.Show("Erreur d'écriture lors de la purge des documents " + extension);
			}
		}
	}
}
