用正则表达式判断是否是正确路径格式C#代码

public static bool IsCorrectPath(string path)
{
if (Validation.IsStringNullOrEmptyOrBlank(path))
{
return false;
}
StringBuilder builder = new StringBuilder();
builder.Append(@"^(([a-zA-Z]":)|(""))(""{1}|((""{1})[^""]([^/:*?<>");
builder.Append("""");
builder.Append("|]*))+)$");
Regex regex = new Regex(builder.ToString());
return regex.IsMatch(path);
}

posted on 2008-05-08 18:32  步走高飞  阅读(2840)  评论(0编辑  收藏  举报

导航