且构网

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

将文件路径转换为文件 URI?

更新时间:2023-02-23 12:05:14

System.Uri 构造函数能够解析完整的文件路径并将它们转换为 URI 样式的路径.因此,您只需执行以下操作:

The System.Uri constructor has the ability to parse full file paths and turn them into URI style paths. So you can just do the following:

var uri = new System.Uri("c:\foo");
var converted = uri.AbsoluteUri;