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 methods are fairly easy to access from within System.IO.Path, however, this doesn't seem to exist within portable class libraries. Is there an open source replacement for this or some other API that would give me the same functionality?
PCL projects target specific profiles that support a known set of BCL classes/features. However, the down side to PCL is that they often require extra architectural effort to separate profile specific code into their own libraries.
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()
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With