ktsu.StrongPaths 1.1.39

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package ktsu.StrongPaths --version 1.1.39                
NuGet\Install-Package ktsu.StrongPaths -Version 1.1.39                
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.1.39" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ktsu.StrongPaths --version 1.1.39                
#r "nuget: ktsu.StrongPaths, 1.1.39"                
#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.
// Install ktsu.StrongPaths as a Cake Addin
#addin nuget:?package=ktsu.StrongPaths&version=1.1.39

// Install ktsu.StrongPaths as a Cake Tool
#tool nuget:?package=ktsu.StrongPaths&version=1.1.39                

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.ImGuiWidgets

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

ktsu.ImGuiApp

A bootstrap library to give you an environment to build an ImGUI.NET application with.

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.1.50 600 1/2/2025
1.1.50-pre.20 21 1/21/2025
1.1.50-pre.19 25 1/20/2025
1.1.50-pre.18 32 1/19/2025
1.1.50-pre.17 28 1/17/2025
1.1.50-pre.16 26 1/15/2025
1.1.50-pre.15 28 1/13/2025
1.1.50-pre.14 29 1/11/2025
1.1.50-pre.13 25 1/10/2025
1.1.50-pre.12 28 1/10/2025
1.1.50-pre.11 8 1/8/2025
1.1.50-pre.10 44 1/7/2025
1.1.50-pre.9 47 1/6/2025
1.1.50-pre.8 60 1/4/2025
1.1.50-pre.7 48 1/3/2025
1.1.50-pre.6 46 1/3/2025
1.1.50-pre.5 46 1/3/2025
1.1.50-pre.4 61 1/1/2025
1.1.50-pre.3 68 12/31/2024
1.1.50-pre.2 48 12/29/2024
1.1.50-pre.1 42 12/28/2024
1.1.49 1,004 12/26/2024
1.1.48 76 12/26/2024
1.1.47 81 12/26/2024
1.1.46 81 12/26/2024
1.1.45 83 12/26/2024
1.1.44 80 12/26/2024
1.1.43 92 12/26/2024
1.1.42 238 12/25/2024
1.1.41 298 12/24/2024
1.1.40 323 12/23/2024
1.1.39 88 12/23/2024
1.1.38 84 12/23/2024
1.1.37 582 12/19/2024
1.1.36 400 12/14/2024
1.1.35 479 12/6/2024
1.1.34 226 12/5/2024
1.1.33 414 12/2/2024
1.1.32 296 12/2/2024
1.1.31 267 12/1/2024
1.1.30 135 12/1/2024
1.1.29 147 11/30/2024
1.1.28 88 11/30/2024
1.1.27 101 11/30/2024
1.1.26 136 11/29/2024
1.1.25 201 11/28/2024
1.1.24 252 11/26/2024
1.1.23 574 11/15/2024
1.1.22 216 11/14/2024
1.1.21 204 11/13/2024
1.1.20 543 11/5/2024
1.1.19 243 11/2/2024
1.1.18 295 11/1/2024
1.1.17 798 10/17/2024
1.1.16 519 10/8/2024
1.1.15 227 10/5/2024
1.1.14 182 10/4/2024
1.1.13 520 9/24/2024
1.1.12 210 9/21/2024
1.1.11 215 9/19/2024
1.1.10 164 9/19/2024
1.1.9 162 9/19/2024
1.1.8 99 9/19/2024
1.1.7 157 9/19/2024
1.1.6 119 9/18/2024
1.1.5 106 9/18/2024
1.1.4 248 9/18/2024
1.1.3 361 9/18/2024
1.1.2 366 9/14/2024