ktsu.StrongPaths
1.1.12
Prefix Reserved
See the version list below for details.
dotnet add package ktsu.StrongPaths --version 1.1.12
NuGet\Install-Package ktsu.StrongPaths -Version 1.1.12
<PackageReference Include="ktsu.StrongPaths" Version="1.1.12" />
paket add ktsu.StrongPaths --version 1.1.12
#r "nuget: ktsu.StrongPaths, 1.1.12"
// Install ktsu.StrongPaths as a Cake Addin #addin nuget:?package=ktsu.StrongPaths&version=1.1.12 // Install ktsu.StrongPaths as a Cake Tool #tool nuget:?package=ktsu.StrongPaths&version=1.1.12
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 themAnyRelativePath
AcceptsRelativePath
,RelativeDirectroryPath
,RelativeFilePath
, and types derived from themAnyAbsolutePath
AcceptsAbsolutePath
,AbsoluteDirectroryPath
,AbsoluteFilePath
, and types derived from themAnyDirectoryPath
AcceptsDirectoryPath
,AbsoluteDirectroryPath
,RelativeDirectroryPath
, and types derived from themAnyFilePath
AcceptsFilePath
,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 | 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. |
-
net7.0
- ktsu.Extensions (>= 1.0.17)
- ktsu.StrongStrings (>= 1.2.7)
-
net8.0
- ktsu.Extensions (>= 1.0.17)
- ktsu.StrongStrings (>= 1.2.7)
NuGet packages (6)
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.ImGuiPopups
A library for custom popups using ImGui.NET. |
|
ktsu.ImGuiWidgets
A library for custom widgets using ImGui.NET. |
|
ktsu.ImGuiApp
A bootstrap library to give you an environment to build an ImGUI.NET application with. |
|
ktsu.CredentialCache
CredentialCache |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.23 | 51 | 11/15/2024 |
1.1.22 | 87 | 11/14/2024 |
1.1.21 | 127 | 11/13/2024 |
1.1.20 | 480 | 11/5/2024 |
1.1.19 | 210 | 11/2/2024 |
1.1.18 | 222 | 11/1/2024 |
1.1.17 | 731 | 10/17/2024 |
1.1.16 | 503 | 10/8/2024 |
1.1.15 | 213 | 10/5/2024 |
1.1.14 | 171 | 10/4/2024 |
1.1.13 | 502 | 9/24/2024 |
1.1.12 | 194 | 9/21/2024 |
1.1.11 | 201 | 9/19/2024 |
1.1.10 | 148 | 9/19/2024 |
1.1.9 | 148 | 9/19/2024 |
1.1.8 | 85 | 9/19/2024 |
1.1.7 | 144 | 9/19/2024 |
1.1.6 | 106 | 9/18/2024 |
1.1.5 | 93 | 9/18/2024 |
1.1.4 | 233 | 9/18/2024 |
1.1.3 | 346 | 9/18/2024 |
1.1.2 | 355 | 9/14/2024 |