ktsu.io.StrongPaths
1.1.1
Prefix Reserved
dotnet add package ktsu.io.StrongPaths --version 1.1.1
NuGet\Install-Package ktsu.io.StrongPaths -Version 1.1.1
<PackageReference Include="ktsu.io.StrongPaths" Version="1.1.1" />
<PackageVersion Include="ktsu.io.StrongPaths" Version="1.1.1" />
<PackageReference Include="ktsu.io.StrongPaths" />
paket add ktsu.io.StrongPaths --version 1.1.1
#r "nuget: ktsu.io.StrongPaths, 1.1.1"
#:package ktsu.io.StrongPaths@1.1.1
#addin nuget:?package=ktsu.io.StrongPaths&version=1.1.1
#tool nuget:?package=ktsu.io.StrongPaths&version=1.1.1
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.io.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.io.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
AbsolutePathRelativePathDirectoryPathFilePathFileNameFileExtensionAbsoluteDirectoryPathRelativeDirectoryPathAbsoluteFilePathRelativeFilePath
Abstract Base Classes
You can use these abstract base classes to accept a subset of path types in your method parameters:
AnyStrongPathAccepts any of the concrete types and types derived from themAnyRelativePathAcceptsRelativePath,RelativeDirectroryPath,RelativeFilePath, and types derived from themAnyAbsolutePathAcceptsAbsolutePath,AbsoluteDirectroryPath,AbsoluteFilePath, and types derived from themAnyDirectoryPathAcceptsDirectoryPath,AbsoluteDirectroryPath,RelativeDirectroryPath, and types derived from themAnyFilePathAcceptsFilePath,AbsoluteFilePath,RelativeFilePath, and types derived from them
using ktsu.io.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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 was computed. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- ktsu.io.Extensions (>= 1.0.7)
- ktsu.io.StrongStrings (>= 1.1.0)
-
net8.0
- ktsu.io.Extensions (>= 1.0.7)
- ktsu.io.StrongStrings (>= 1.1.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on ktsu.io.StrongPaths:
| Package | Downloads |
|---|---|
|
ktsu.io.ImGuiWidgets
A library for custom widgets using ImGui.NET. |
|
|
ktsu.io.ImGuiApp
A bootstrap library to give you an environment to build an ImGUI.NET application with. |
|
|
ktsu.io.AppDataStorage
Application data management library using JSON serialization to save and load data in the user's app data folder. |
|
|
ktsu.io.ImGuiPopups
A library for custom popups using ImGui.NET. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.1.1 | 2,010 | 8/22/2024 | |
| 1.1.0 | 240 | 8/21/2024 | |
| 1.0.8 | 1,361 | 4/1/2024 | |
| 1.0.7 | 257 | 3/27/2024 | |
| 1.0.6 | 206 | 3/26/2024 | |
| 1.0.5 | 210 | 3/26/2024 | |
| 1.0.4 | 196 | 3/25/2024 | |
| 1.0.3 | 187 | 3/25/2024 | |
| 1.0.2 | 206 | 3/21/2024 | |
| 1.0.1 | 198 | 3/21/2024 | |
| 1.0.0 | 363 | 3/7/2024 | |
| 1.0.0-alpha.6 | 144 | 2/29/2024 | |
| 1.0.0-alpha.5 | 231 | 1/11/2024 | |
| 1.0.0-alpha.4 | 147 | 1/11/2024 | |
| 1.0.0-alpha.3 | 189 | 12/26/2023 | |
| 1.0.0-alpha.2 | 166 | 12/19/2023 | |
| 1.0.0-alpha.1 | 198 | 6/1/2023 |