Meziantou.Framework.FullPath
1.0.11
.NET 6.0
.NET Core 3.1
.NET Framework 4.7.2
dotnet add package Meziantou.Framework.FullPath --version 1.0.11
NuGet\Install-Package Meziantou.Framework.FullPath -Version 1.0.11
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="Meziantou.Framework.FullPath" Version="1.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Meziantou.Framework.FullPath --version 1.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Meziantou.Framework.FullPath, 1.0.11"
#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 Meziantou.Framework.FullPath as a Cake Addin
#addin nuget:?package=Meziantou.Framework.FullPath&version=1.0.11
// Install Meziantou.Framework.FullPath as a Cake Tool
#tool nuget:?package=Meziantou.Framework.FullPath&version=1.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Meziantou.Framework.FullPath
FullPath
ensures you always deal with full path in your application and provides many common methods to manipulate paths.
// Create FullPath
FullPath rootPath = FullPath.FromPath("demo"); // It automatically calls Path.GetFullPath to resolve the path
FullPath filePath = FullPath.Combine(rootPath, "temp", "meziantou.txt"); // Use Path.Combine to join paths (you can combine as many path as you needed)
FullPath temp = FullPath.GetTempPath(); // equivalent of Path.GetTempPath()
FullPath cwd = FullPath.GetCurrentDirectory(); // equivalent of Environment.CurrentDirectory
// Combine path: you can use the / operator to join path
FullPath filePath1 = rootPath / "temp" / "meziantou.txt";
// Compare path
// Comparisons are case-insensitive on Windows and case-sensitive on other operating systems by default
_ = filePath == rootPath;
_ = filePath.Equals(rootPath, ignoreCase: false);
// Get parent directory
FullPath parent = filePath.Parent;
// Get file/directory name - extension
var name = filePath.Name;
var ext = filePath.Extension;
// Make relative path
string relativePath = filePath.MakeRelativeTo(rootPath); // temp\meziantou.txt
// Check if a path is under another path
bool isChildOf = filePath.IsChildOf(rootPath);
// FullPath is implicitly converted to string, so it works well with File/Directory methods
System.IO.File.WriteAllText(filePath, content);
Additional resources
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp3.1 |
.NET Framework | net472 net48 net481 |
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Mono.Posix.NETStandard (>= 1.0.0)
-
.NETFramework 4.7.2
- System.Text.Json (>= 6.0.5)
-
net6.0
- Mono.Posix.NETStandard (>= 1.0.0)
-
net7.0
- Mono.Posix.NETStandard (>= 1.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Meziantou.Framework.FullPath:
Package | Downloads |
---|---|
Meziantou.Framework.TemporaryDirectory
Package Description |
|
Meziantou.Framework.NuGetPackageValidation
Provide rules to validate a NuGet package follows best practices |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Meziantou.Framework.FullPath:
Repository | Stars |
---|---|
meziantou/Meziantou.Analyzer
A Roslyn analyzer to enforce some good practices in C#.
|