Is there a way to easily parse file paths in portable class libraries?

后端 未结 2 781
南笙
南笙 2021-01-17 12:15

I\'m needing to parse a path into parts from within a portable class library and get things like the filename, extension, just directory name, etc.

All of these met

相关标签:
2条回答
  • 2021-01-17 12:19

    You may be able to use or adapt the code for System.IO.Path from Mono: https://github.com/mono/mono/blob/master/mcs/class/corlib/System.IO/Path.cs

    EDIT: Also, my PCL Storage library provides some file IO APIs to PCLs, including PortablePath.Combine().

    0 讨论(0)
  • 2021-01-17 12:21

    I would use Uri class

    var segments = new Uri("file://c:/dir1/dir2/a.txt").Segments
    

    which is supported by PCL

    http://msdn.microsoft.com/en-us/library/system.uri.aspx

    0 讨论(0)
提交回复
热议问题