jhtools.filesystem 0.2.1

dotnet add package jhtools.filesystem --version 0.2.1
NuGet\Install-Package jhtools.filesystem -Version 0.2.1
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="jhtools.filesystem" Version="0.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add jhtools.filesystem --version 0.2.1
#r "nuget: jhtools.filesystem, 0.2.1"
#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 jhtools.filesystem as a Cake Addin
#addin nuget:?package=jhtools.filesystem&version=0.2.1

// Install jhtools.filesystem as a Cake Tool
#tool nuget:?package=jhtools.filesystem&version=0.2.1

JHTools.FileSystem

A library of extensions to DirectoryInfo and FileInfo

Installation

nuget install jhtools.filesystem

Usage

using JHTools.FileSystem;

var d = new DirectoryInfo(@"C:\Temp");

var fileInfo = d.GetFile("test.txt"); // returns a FileInfo object for the file
var directoryInfo = d.GetDirectory("test"); // returns a DirectoryInfo object for the directory

fileInfo = d.GetExistingFile("test.txt"); // returns a FileInfo object for the file, or throws an exception if the file does not exist
directoryInfo = d.GetExistingDirectory("test"); // returns a DirectoryInfo object for the directory, or throws an exception if the directory does not exist

d.EnsureDeleted(); // deletes the directory if it exists
d.EnsureCreated(); // creates the directory if it does not exist
d.EnsureEmpty(); // makes sure the directory exists and is empty
await d.CopyToAsync(@"C:\Temp2", CopyOperation.?); // copies the directory to the specified location
d.CreateZipFile(@"C:\Temp2\test.zip"); // creates a zip file of the directory
d.ReadJsonFile<TestObject>("test.json"); // reads a json file from the directory
d.WriteJsonFile("test.json", new TestObject()); // writes a json file to the directory
d.UnzipTo(@"C:\Temp2"); // unzips a zip file to the directory

FileLock

The file lock class can be used to lock a file for exclusive access. This is useful when you want to make sure that only one process can access a file at a time.

var factory = new FileLockFactory();
using var fileLock = factory.Create(@"C:\Temp\test.txt");
{
    // do something with lock
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.1 194 9/7/2022
0.2.0 169 9/7/2022