Ear*_*rlz 12 .net c# file path portable-class-library
我需要从一个可移植的类库中解析一个路径,然后得到文件名,扩展名,目录名等等.
所有这些方法都很容易从System.IO.Path中访问,但是,这似乎不存在于可移植类库中.是否有这个或其他API的开源替代品可以提供相同的功能?
您可以使用或调整Mono的System.IO.Path代码:https://github.com/mono/mono/blob/master/mcs/class/corlib/System.IO/Path.cs
编辑:此外,我的PCL存储库为PCL提供了一些文件IO API,包括PortablePath.Combine()
.
我会使用Uri
类
var segments = new Uri("file://c:/dir1/dir2/a.txt").Segments
Run Code Online (Sandbox Code Playgroud)
PCL 支持
http://msdn.microsoft.com/en-us/library/system.uri.aspx