A quick look at FluentPath

 

I find the System.IO namespace a little clumsy to work with sometimes. I had some code which wanted to navigate my solutions structure to access an assembly somewhere. It’s illustrated below.

image

Here’s the solution with System.IO:

var path = Path.Combine(
    new DirectoryInfo(
    Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName,
    "Warp.Profiler.Unit.Tests.SampleAssembly\\bin\\Debug");

Perhaps there’s an easier and neater way, but this is the way I found intuitive to do. Now here’s the same using FluentPath.

var path = Path.Current
               .Up(3)
               .Combine("Warp.Profiler.Unit.Tests.SampleAssembly", "bin", "Debug");

That’s a good improvement in readability and I found it more intuitive to write. Give it a try and see how you like it.

http://fluentpath.codeplex.com/

blog comments powered by Disqus