正则表达式校验文件路径

public static bool CheckPath(string path)
{
    string pattern = @"^[a-zA-Z]:(((\\(?! )[^/:*?<>\""|\\]+)+\\?)|(\\)?)\s*$";
    Regex regex = new Regex(pattern);
    return regex.IsMatch(path);
} 

 

posted @ 2015-09-28 13:53  沙耶  阅读(13429)  评论(0编辑  收藏  举报