/// <summary>
		/// Ensures that the specified directory exists, otherwise creates it. Raises the CreateDirectoryFailed event upon failure to allow user intervention.
		/// </summary>
		/// <param name="path">The path to the directory, this should be a directory, not including the filename, othewise a directory with the file name will be created.</param>
		/// <param name="userData">User specified data to be raised during event notification</param>
		/// <returns></returns>
		public static bool CreateDirectory(string path, object sender, object userData)
		{
			try
			{				
				if (!Directory.Exists(path))
					Directory.CreateDirectory(path);
				return true;
			}
			catch(System.Exception systemException)
			{
				PathCreationEngineEventArgs e = new PathCreationEngineEventArgs(path);
				e.Exception = systemException;
				e.UserData = userData;
				PathCreationEngine.OnCreateDirectoryFailed(sender, e);

				switch(e.Result)
				{
				case DialogResult.OK:
					return true;

				case DialogResult.Cancel:
					return false;

				case DialogResult.Abort:					
					return false;					

				case DialogResult.Retry:
					return PathCreationEngine.CreateDirectory(path, sender, userData);					

				case DialogResult.Ignore:
					return true;					
				};
			}
			return false;		
		}
 private static void OnDeleteFileFailed(object sender, PathCreationEngineEventArgs e)
 {
     try
     {
         if (PathCreationEngine.DeleteFileFailed != null)
         {
             PathCreationEngine.DeleteFileFailed(sender, e);
         }
     }
     catch (System.Exception systemException)
     {
         System.Diagnostics.Trace.WriteLine(systemException);
     }
 }
        /// <summary>
        /// Delete's the specified path if it exists. Raises the DeleteFileFailed event upon failure to allow user intervention.
        /// </summary>
        /// <param name="path">The path to delete, can be a file or directory</param>
        /// <param name="userData">User specified data to be raised during event notification</param>
        /// <returns></returns>
        public static bool DeleteFile(string path, object sender, object userData)
        {
            try
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                return(true);
            }
            catch (System.Exception systemException)
            {
                PathCreationEngineEventArgs e = new PathCreationEngineEventArgs(path);
                e.Exception = systemException;
                e.UserData  = userData;
                PathCreationEngine.OnDeleteFileFailed(sender, e);

                switch (e.Result)
                {
                case DialogResult.OK:
                    return(true);

                case DialogResult.Cancel:
                    return(false);

                case DialogResult.Abort:
                    return(false);

                case DialogResult.Retry:
                    return(PathCreationEngine.DeleteFile(path, sender, userData));

                case DialogResult.Ignore:
                    return(true);
                }
                ;
            }
            return(false);
        }
		private static void OnDeleteFileFailed(object sender, PathCreationEngineEventArgs e)
		{
			try
			{
				if (PathCreationEngine.DeleteFileFailed != null)
					PathCreationEngine.DeleteFileFailed(sender, e);
			}
			catch(System.Exception systemException)
			{
				System.Diagnostics.Trace.WriteLine(systemException);
			}
		}	
		/// <summary>
		/// Handles the DeleteFileFailed event from the PathCreationEngine
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		internal static void OnPathCreationEngineDeleteFileFailed(object sender, PathCreationEngineEventArgs e)
		{
			if (e.UserData != null)
			{
				string key = e.UserData as string;
				if (key != null)
				{
					switch (key)
					{
					case SnapInHostingEngine.DefaultCommonConfigurationName:
						
						if (_verbose)
						{
							e.Result = ExceptionEngine.DisplayException(
								null,
								"Exception encountered - Unable to delete configuration",
								MessageBoxIcon.Error,
								MessageBoxButtons.OK, 
								e.Exception,
								"The configuration '" + SnapInHostingEngine.DefaultCommonConfigurationName + "' could not be deleted.");
						}
						else
						{
							e.Result = DialogResult.OK;
						}
						break;

					case SnapInHostingEngine.DefaultLocalUserConfigurationName:					
						
						if (_verbose)
						{
							e.Result = ExceptionEngine.DisplayException(
								null,
								"Exception encountered - Unable to delete configuration",
								MessageBoxIcon.Error,
								MessageBoxButtons.OK, 
								e.Exception,
								"The configuration '" + SnapInHostingEngine.DefaultLocalUserConfigurationName + "' could not be deleted.");
						}
						else
						{
							e.Result = DialogResult.OK;
						}
						break;
					};
				}
			}
		}
		/// <summary>
		/// Handles the CreateDirectoryFailed event from the PathCreationEngine
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		internal static void OnPathCreationEngineCreateDirectoryFailed(object sender, PathCreationEngineEventArgs e)
		{
			if (e.UserData != null)
			{
				string key = e.UserData as string;
				if (key != null)
				{
					switch (key)
					{
					case "CommonDataPath":
						
						if (_verbose)
						{
							e.Result = ExceptionEngine.DisplayException(
								null,
								"Exception encountered - Unable to create common data directory",
								MessageBoxIcon.Error,
								MessageBoxButtons.AbortRetryIgnore, 
								e.Exception,
								"The path '" + e.Path + "' must exist in order to save data common to all users.",
								"Ignoring this exception could result in a loss of data or further exceptions.",					
								"Typical settings may include network, security, or other application related settings.",
								"Data in this path should be considered vital to the functionality and performance of the application.",					
								"WARNING: Aborting this operation will exit the application!");
						}
						else
						{
							e.Result = DialogResult.Ignore;
						}
						break;

					case "LocalUserDataPath":						
						
						if (_verbose)
						{
							e.Result = ExceptionEngine.DisplayException(
								null,
								"Exception encountered - Unable to create local user data directory",
								MessageBoxIcon.Error,
								MessageBoxButtons.AbortRetryIgnore, 
								e.Exception,
								"The path '" + e.Path + "' must exist in order to save data particular to the current user '" + System.Environment.UserName + "'.",
								"Ignoring this exception could result in a loss of data or further exceptions.",					
								"Typical settings may include window positions and other user interface related settings.",
								"Data in this path should be considered non-vital to the functionality and performance of the application.",					
								"WARNING: Aborting this operation will exit the application!");
						}
						else
						{
							e.Result = DialogResult.Ignore;
						}
						break;

					case "LogsDataPath":

						if (_verbose)
						{
							e.Result = ExceptionEngine.DisplayException(
								null,
								"Exception encountered - Unable to create the logs directory",
								MessageBoxIcon.Error,
								MessageBoxButtons.AbortRetryIgnore, 
								e.Exception,
								"The path '" + e.Path + "' must exist in order to save a log file containing debugging information.",
								"Ignoring this exception will not affect the performance of the application, however no debugging information will be saved for this instance of the program.",					
								"Data in this path should be considered usefull for debugging purposes only.",					
								"WARNING: Aborting this operation will exit the application!");
						}
						else
						{
							e.Result = DialogResult.Ignore;
						}

						if (e.Result == DialogResult.Ignore)
							_noLog = true;

						break;
					};


				}
			}
		}