ktsu.StrongPaths 1.3.0

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package ktsu.StrongPaths --version 1.3.0
                    
NuGet\Install-Package ktsu.StrongPaths -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ktsu.StrongPaths" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ktsu.StrongPaths" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="ktsu.StrongPaths" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ktsu.StrongPaths --version 1.3.0
                    
#r "nuget: ktsu.StrongPaths, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ktsu.StrongPaths&version=1.3.0
                    
Install ktsu.StrongPaths as a Cake Addin
#tool nuget:?package=ktsu.StrongPaths&version=1.3.0
                    
Install ktsu.StrongPaths as a Cake Tool

StrongPaths

A library that provides strong typing for common filesystem paths providing compile time feedback and runtime validation.

StrongPaths is a collection of classes derived from ktsu.StrongStrings with added functionality and helper methods for filesystem paths.

Get familiar with the StrongStrings library to get the most out of StrongPaths.

Usage

using ktsu.StrongPaths;

public class MyDemoClass
{
	public AbsoluteDirectoryPath OutputDir { get; set; } = (AbsoluteDirectoryPath)@"c:\output";

	public void SaveData(RelativeDirectoryPath subDir, FileName fileName)
	{
		// You can use the / operator to combine paths
		AbsoluteFilePath filePath = OutputDir / subDir / fileName;
		File.WriteAllText(filePath, "Hello, world!");

		// An AbsoluteDirectoryPath combined with a RelativeDirectoryPath returns an AbsoluteDirectoryPath
		AbsoluteDirectoryPath newOutputDir = OutputDir / subDir;

		// An AbsoluteDirectoryPath combined with a FileName returns an AbsoluteFilePath
		AbsoluteFilePath newFilePath = newOutputDir / fileName;

		// You can get a relative path from Absolute/Relative Directory/File paths using the RelativeTo method
		RelativeDirectoryPath relativePath = newOutputDir.RelativeTo(OutputDir);
		RelativeFilePath relativeFilePath = newFilePath.RelativeTo(OutputDir);
		RelativeDirectoryPath relativePath2 = newOutputDir.RelativeTo(filePath);
		RelativeFilePath relativeFilePath2 = newFilePath.RelativeTo(filePath);
	}

	public void Demo()
	{
		string storeLocation = "melbourne";
		RelativeDirectoryPath storeDir = (RelativeDirectoryPath)$"store_{storeLocation}";
		FileName fileName = (FileName)$"{DateTime.UtcNow}.json";
		SaveData(storeDir, fileName);
	}
}

Concrete Types

  • AbsolutePath
  • RelativePath
  • DirectoryPath
  • FilePath
  • FileName
  • FileExtension
  • AbsoluteDirectoryPath
  • RelativeDirectoryPath
  • AbsoluteFilePath
  • RelativeFilePath

Abstract Base Classes

You can use these abstract base classes to accept a subset of path types in your method parameters:

  • AnyStrongPath Accepts any of the concrete types and types derived from them
  • AnyRelativePath Accepts RelativePath, RelativeDirectroryPath, RelativeFilePath, and types derived from them
  • AnyAbsolutePath Accepts AbsolutePath, AbsoluteDirectroryPath, AbsoluteFilePath, and types derived from them
  • AnyDirectoryPath Accepts DirectoryPath, AbsoluteDirectroryPath, RelativeDirectroryPath, and types derived from them
  • AnyFilePath Accepts FilePath, AbsoluteFilePath, RelativeFilePath, and types derived from them
using ktsu.StrongPaths;

public static class MyDemoClass
{
	public static void SaveData(AnyDirectoryPath outputDir, FileName fileName)
	{
		// You can't use the / operator with the abstract base classes because it has no way of knowing which type to return
		// You have to use the Path.Combine method when using the abstract base classes
		FilePath filePath = (FilePath)Path.Combine(outputDir, fileName);
		File.WriteAllText(filePath, "Hello, World!");
	}

    public static void Demo()
	{
		string storeLocation = "melbourne";
		RelativeDirectoryPath storeDir = (RelativeDirectoryPath)$"store_{storeLocation}";
		FileName fileName = (FileName)$"{DateTime.UtcNow}.json";
		SaveData(storeDir, fileName);
	}
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on ktsu.StrongPaths:

Package Downloads
ktsu.AppDataStorage

Application data management library using JSON serialization to save and load data in the user's app data folder.

ktsu.ImGuiApp

A scaffolding library to create Dear ImGui applications in .NET

ktsu.ImGuiWidgets

A library of custom widgets using ImGui.NET and utilities to enhance ImGui-based applications.

ktsu.ImGuiPopups

A library for custom popups using ImGui.NET.

ktsu.CredentialCache

CredentialCache

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1-pre.1 98 4/4/2025
1.3.0 518 3/30/2025
1.2.1-pre.3 61 3/29/2025
1.2.1-pre.2 440 3/25/2025
1.2.1-pre.1 64 2/18/2025
1.2.0 1,641 2/17/2025
1.1.51-pre.3 61 2/6/2025
1.1.51-pre.2 52 2/5/2025
1.1.51-pre.1 55 2/5/2025
1.1.50 2,966 1/2/2025
1.1.50-pre.28 55 2/4/2025
1.1.50-pre.27 58 2/3/2025
1.1.50-pre.26 55 2/2/2025
1.1.50-pre.25 57 1/31/2025
1.1.50-pre.24 45 1/29/2025
1.1.50-pre.23 46 1/27/2025
1.1.50-pre.22 52 1/25/2025
1.1.50-pre.21 48 1/23/2025
1.1.50-pre.20 51 1/21/2025
1.1.50-pre.19 46 1/20/2025
1.1.50-pre.18 47 1/19/2025
1.1.50-pre.17 45 1/17/2025
1.1.50-pre.16 39 1/15/2025
1.1.50-pre.15 46 1/13/2025
1.1.50-pre.14 50 1/11/2025
1.1.50-pre.13 45 1/10/2025
1.1.50-pre.12 48 1/10/2025
1.1.50-pre.11 41 1/8/2025
1.1.50-pre.10 55 1/7/2025
1.1.50-pre.9 58 1/6/2025
1.1.50-pre.8 71 1/4/2025
1.1.50-pre.7 59 1/3/2025
1.1.50-pre.6 57 1/3/2025
1.1.50-pre.5 58 1/3/2025
1.1.50-pre.4 72 1/1/2025
1.1.50-pre.3 80 12/31/2024
1.1.50-pre.2 59 12/29/2024
1.1.50-pre.1 53 12/28/2024
1.1.49 1,753 12/26/2024
1.1.48 88 12/26/2024
1.1.47 93 12/26/2024
1.1.46 93 12/26/2024
1.1.45 95 12/26/2024
1.1.44 90 12/26/2024
1.1.43 103 12/26/2024
1.1.42 255 12/25/2024
1.1.41 310 12/24/2024
1.1.40 334 12/23/2024
1.1.39 98 12/23/2024
1.1.38 95 12/23/2024
1.1.37 593 12/19/2024
1.1.36 410 12/14/2024
1.1.35 488 12/6/2024
1.1.34 232 12/5/2024
1.1.33 421 12/2/2024
1.1.32 303 12/2/2024
1.1.31 273 12/1/2024
1.1.30 141 12/1/2024
1.1.29 153 11/30/2024
1.1.28 94 11/30/2024
1.1.27 106 11/30/2024
1.1.26 142 11/29/2024
1.1.25 208 11/28/2024
1.1.24 259 11/26/2024
1.1.23 582 11/15/2024
1.1.22 224 11/14/2024
1.1.21 209 11/13/2024
1.1.20 548 11/5/2024
1.1.19 247 11/2/2024
1.1.18 302 11/1/2024
1.1.17 802 10/17/2024
1.1.16 523 10/8/2024
1.1.15 232 10/5/2024
1.1.14 188 10/4/2024
1.1.13 522 9/24/2024
1.1.12 215 9/21/2024
1.1.11 218 9/19/2024
1.1.10 168 9/19/2024
1.1.9 165 9/19/2024
1.1.8 102 9/19/2024
1.1.7 160 9/19/2024
1.1.6 123 9/18/2024
1.1.5 108 9/18/2024
1.1.4 250 9/18/2024
1.1.3 365 9/18/2024
1.1.2 368 9/14/2024

## v1.3.0 (minor)

Changes since v1.2.0:

- Add LICENSE template ([@matt-edmondson](https://github.com/matt-edmondson))

## v1.2.0 (minor)

Changes since 1.1.0:

- Add automation scripts for metadata management and versioning ([@matt-edmondson](https://github.com/matt-edmondson))
- Apply new editorconfig ([@matt-edmondson](https://github.com/matt-edmondson))
- Ensure paths are fully qualified in IsValid method ([@matt-edmondson](https://github.com/matt-edmondson))
- Fix crash when using prefix/suffix methods ([@matt-edmondson](https://github.com/matt-edmondson))
- Migrate ktsu.io to ktsu namespace ([@matt-edmondson](https://github.com/matt-edmondson))
- Refactor MakeCanonical and update Tests.cs namespace ([@matt-edmondson](https://github.com/matt-edmondson))
- Refactor test assertions in Tests.cs ([@matt-edmondson](https://github.com/matt-edmondson))
- Renamed metadata files ([@matt-edmondson](https://github.com/matt-edmondson))
- Replace LICENSE file with LICENSE.md and update copyright information ([@matt-edmondson](https://github.com/matt-edmondson))
- Update StrongStrings subproject reference ([@matt-edmondson](https://github.com/matt-edmondson))

## v1.1.50 (patch)

Changes since v1.1.49:

- Add automation scripts for metadata management and versioning ([@matt-edmondson](https://github.com/matt-edmondson))
- Renamed metadata files ([@matt-edmondson](https://github.com/matt-edmondson))

## v1.1.45 (patch)

Changes since v1.1.44:

- Replace LICENSE file with LICENSE.md and update copyright information ([@matt-edmondson](https://github.com/matt-edmondson))

## v1.1.38 (patch)

Changes since v1.1.37:

- Refactor test assertions in Tests.cs ([@matt-edmondson](https://github.com/matt-edmondson))
- Update StrongStrings subproject reference ([@matt-edmondson](https://github.com/matt-edmondson))

## v1.1.29 (patch)

Changes since v1.1.28:

- Ensure paths are fully qualified in IsValid method ([@matt-edmondson](https://github.com/matt-edmondson))

## v1.1.28 (patch)

Changes since v1.1.27:

- Refactor MakeCanonical and update Tests.cs namespace ([@matt-edmondson](https://github.com/matt-edmondson))

## v1.1.2 (minor)

Changes since v1.0.8:

- Add WithFilePrefix ([@matt-edmondson](https://github.com/matt-edmondson))
- Fix crash when using prefix/suffix methods ([@matt-edmondson](https://github.com/matt-edmondson))
- Migrate ktsu.io to ktsu namespace ([@matt-edmondson](https://github.com/matt-edmondson))

## v1.0.8 (major)

Changes since 0.0.0.0:

- Add a property to get the filesystem contents from directories ([@matt-edmondson](https://github.com/matt-edmondson))
- Add github package support ([@matt-edmondson](https://github.com/matt-edmondson))
- Add helper properties to top level paths ([@matt-edmondson](https://github.com/matt-edmondson))
- Add IsDirectory  and IsFile  properties ([@matt-edmondson](https://github.com/matt-edmondson))
- Add path combine operators to common path types ([@matt-edmondson](https://github.com/matt-edmondson))
- Add RelativeTo helper methods ([@matt-edmondson](https://github.com/matt-edmondson))
- Add some common path types like absolute and relative file and directory paths ([@matt-edmondson](https://github.com/matt-edmondson))
- Adjust unit test to work on linux ([@matt-edmondson](https://github.com/matt-edmondson))
- Allow paths to be empty ([@matt-edmondson](https://github.com/matt-edmondson))
- Assign dependabot PRs to matt ([@matt-edmondson](https://github.com/matt-edmondson))
- Avoid double upload of symbols package ([@matt-edmondson](https://github.com/matt-edmondson))
- Bump version to 1.0.0-alpha.2 ([@matt-edmondson](https://github.com/matt-edmondson))
- Chnage path separators to make code gen work on github ([@matt-edmondson](https://github.com/matt-edmondson))
- Create dependabot-merge.yml ([@matt-edmondson](https://github.com/matt-edmondson))
- Create VERSION ([@matt-edmondson](https://github.com/matt-edmondson))
- Don't crash when trying to get the contents of an unauthorized directory, just return nothing instead ([@matt-edmondson](https://github.com/matt-edmondson))
- Dont try to push packages when building pull requests ([@matt-edmondson](https://github.com/matt-edmondson))
- Enable dependabot and sourcelink ([@matt-edmondson](https://github.com/matt-edmondson))
- Fix issue with RelativeTo not working correctly and add additional unit tests ([@matt-edmondson](https://github.com/matt-edmondson))
- Fix style warnings for ArgumentNullException.ThrowIfNull and take latest StrongStrings ([@matt-edmondson](https://github.com/matt-edmondson))
- Fixed an issue where a directory in the CWD that had periods in the name would not validate as a directory path. Also code style cleanup. ([@matt-edmondson](https://github.com/matt-edmondson))
- Initial WIP commit ([@matt-edmondson](https://github.com/matt-edmondson))
- Make the RelativePath Make method public Add a FileName property to AnyStrongPath Take latest StrongStrings ([@matt-edmondson](https://github.com/matt-edmondson))
- Make unit tests work on linux ([@matt-edmondson](https://github.com/matt-edmondson))
- Make unit tests work with linux ([@matt-edmondson](https://github.com/matt-edmondson))
- Migrate from .project.props to Directory.Build.props ([@matt-edmondson](https://github.com/matt-edmondson))
- Move some file specific properties into AnyFilePath add a DirectoryPath property to FilePath ([@matt-edmondson](https://github.com/matt-edmondson))
- Read from AUTHORS file during build ([@matt-edmondson](https://github.com/matt-edmondson))
- Read from VERSION when building ([@matt-edmondson](https://github.com/matt-edmondson))
- Read PackageDescription from DESCRIPTION file ([@matt-edmondson](https://github.com/matt-edmondson))
- Readd strongstrings so that we can share the csx scripts it uses for code generation ([@matt-edmondson](https://github.com/matt-edmondson))
- Refactor AnyFilePath and update StrongStrings ([@matt-edmondson](https://github.com/matt-edmondson))
- Take latest StrongStrings ([@matt-edmondson](https://github.com/matt-edmondson))
- Update build config ([@matt-edmondson](https://github.com/matt-edmondson))
- Update Directory.Build.props ([@matt-edmondson](https://github.com/matt-edmondson))
- Update Directory.Build.targets ([@matt-edmondson](https://github.com/matt-edmondson))
- Update dotnet.yml ([@matt-edmondson](https://github.com/matt-edmondson))
- Update LICENSE ([@matt-edmondson](https://github.com/matt-edmondson))
- Update nuget.config ([@matt-edmondson](https://github.com/matt-edmondson))
- Update readme and description ([@matt-edmondson](https://github.com/matt-edmondson))
- Update README.md ([@matt-edmondson](https://github.com/matt-edmondson))
- Update StrongStrings ([@matt-edmondson](https://github.com/matt-edmondson))
- Use code generation to make all the user facing classes and add some unit tests ([@matt-edmondson](https://github.com/matt-edmondson))
- Use package reference instead of project reference to StrongStrings ([@matt-edmondson](https://github.com/matt-edmondson))
- WIP ([@matt-edmondson](https://github.com/matt-edmondson))
- WIP while trying to figure out the use cases for StrongStrings ([@matt-edmondson](https://github.com/matt-edmondson))