This is a library containing a set of types to work with file system paths in .NET.
Historically, .NET has been lacking a good set of types to work with file system paths. The System.IO.Path class has a variety of methods that operate on path strings, but it doesn't provide any types to represent paths themselves. It's impossible to tell whether a method accepts an absolute path, a relative path, a file name, or something file-related at all, only looking at its signature: all these types are represented by plain strings. Also, comparing different paths is not straightforward.
This library aims to fill this gap by providing a set of types that represent paths in a strongly-typed way. Now, you can require a path in a method's parameters, and it is guaranteed that the passed path will be well-formed and will have certain properties.
Also, the methods in the library provide some qualities that are missing from the System.IO.Path: say, we aim to provide several ways of path normalization and comparison, the ones that will and will not perform disk IO to resolve paths on case-insensitive file systems.
The library is inspired by the path libraries used in other ecosystems, in no particular order:
- Java's java.nio.file.Path and Kotlin's extensions for general API shape;
- [fs.path.append] from the C++ standard for path concatenation algorithms.
Read more on the documentation site.
If you miss some feature or have questions, do not hesitate to open an issue or go to the discussions section.
| Name | NuGet Package | Documentation |
|---|---|---|
| TruePath | API Reference | |
| TruePath.SystemIo | API Reference | |
| TruePath.TestableIO.System.IO (third-party) | Documentation |
TruePath provides two NuGet packages:
- TruePath for the main path abstractions,
- TruePath.SystemIo for the
System.IOintegration.
A third-party package, TruePath.TestableIO.System.IO, adds TestableIO.System.IO.Abstractions integration on top of TruePath.
This project follows Semantic Versioning, with one exception: the behavior of the types and members marked as [System.Diagnostics.CodeAnalysis.ExperimentalAttribute] may change without a major version bump. Using them causes the compiler to report diagnostic TRUEPATH001; suppress it (e.g. by adding <NoWarn>$(NoWarn);TRUEPATH001</NoWarn> into your project file, or with #pragma warning disable TRUEPATH001) to acknowledge that.
The project is distributed under the terms of the MIT license.
The license indication in the project's sources is compliant with the REUSE specification v3.3.