且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查一个字符串是否是一个有效的Windows目录/文件夹路径?

更新时间:2023-11-29 08:55:16

Path.GetFullPath ;如果路径无效,它会抛出异常。

Call Path.GetFullPath; it will throw exceptions if the path is invalid.

要禁止相对路径(如),呼叫 Path.IsPathRooted

To disallow relative paths (such as Word), call Path.IsPathRooted.