Nexus.Client.Util.FileUtil.ContainsInvalidPathChars C# (CSharp) Method

ContainsInvalidPathChars() public static method

Determines if the given path contains invalid characters.
public static ContainsInvalidPathChars ( string p_strPath ) : bool
p_strPath string The path to examine.
return bool
		public static bool ContainsInvalidPathChars(string p_strPath)
		{
			if (String.IsNullOrEmpty(p_strPath))
				return false;
			Set<string> setChars = new Set<string>();

			string strPath = Path.GetDirectoryName(p_strPath);
			if (!String.IsNullOrEmpty(strPath))
			{
				foreach (char chrInvalidChar in Path.GetInvalidPathChars())
					setChars.Add("\\x" + ((Int32)chrInvalidChar).ToString("x2"));
				Regex rgxInvalidPath = new Regex("[" + String.Join("", setChars.ToArray()) + "]");
				if (rgxInvalidPath.IsMatch(strPath))
					return true;
			}

			string strFile = Path.GetFileName(p_strPath);
			if (String.IsNullOrEmpty(strPath))
				return false;
			setChars.Clear();
			foreach (char chrInvalidChar in Path.GetInvalidFileNameChars())
				setChars.Add("\\x" + ((Int32)chrInvalidChar).ToString("x2"));
			Regex rgxInvalidFile = new Regex("[" + String.Join("", setChars.ToArray()) + "]");
			return rgxInvalidFile.IsMatch(strFile);
		}