#region private static class FindFilesPatternToRegex
private static class FindFilesPatternToRegex
{
	private static Regex HasQuestionMarkRegEx = new Regex(@"\?", RegexOptions.Compiled);
	private static Regex IlegalCharactersRegex = new Regex("[" + @"\/:<>|" + "\"]", RegexOptions.Compiled);
	private static Regex CatchExtentionRegex = new Regex(@"^\s*.+\.([^\.]+)\s*$", RegexOptions.Compiled);
	private static string NonDotCharacters = @"[^.]*";
	public static Regex Convert(string pattern)
	{
		if (pattern == null)
		{
			throw new ArgumentNullException();
		}
		pattern = pattern.Trim();
		if (pattern.Length == 0)
		{
			throw new ArgumentException("Pattern is empty.");
		}
		if (IlegalCharactersRegex.IsMatch(pattern))
		{
			throw new ArgumentException("Patterns contains ilegal characters.");
		}
		bool hasExtension = CatchExtentionRegex.IsMatch(pattern);
		bool matchExact = false;
		if (HasQuestionMarkRegEx.IsMatch(pattern))
		{
			matchExact = true;
		}
		else if (hasExtension)
		{
			matchExact = CatchExtentionRegex.Match(pattern).Groups[1].Length != 3;
		}
		string regexString = Regex.Escape(pattern);
		regexString = "^" + Regex.Replace(regexString, @"\\\*", ".*");
		regexString = Regex.Replace(regexString, @"\\\?", ".");
		if (!matchExact && hasExtension)
		{
			regexString += NonDotCharacters;
		}
		regexString += "$";
		Regex regex = new Regex(regexString, RegexOptions.Compiled | RegexOptions.IgnoreCase);
		return regex;
	}
}
#endregion private static class FindFilesPatternToRegex