Czlovek.Files 2.1.0-beta.82

This is a prerelease version of Czlovek.Files.
dotnet add package Czlovek.Files --version 2.1.0-beta.82
                    
NuGet\Install-Package Czlovek.Files -Version 2.1.0-beta.82
                    
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="Czlovek.Files" Version="2.1.0-beta.82" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Czlovek.Files" Version="2.1.0-beta.82" />
                    
Directory.Packages.props
<PackageReference Include="Czlovek.Files" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Czlovek.Files --version 2.1.0-beta.82
                    
#r "nuget: Czlovek.Files, 2.1.0-beta.82"
                    
#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.
#:package Czlovek.Files@2.1.0-beta.82
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Czlovek.Files&version=2.1.0-beta.82&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Czlovek.Files&version=2.1.0-beta.82&prerelease
                    
Install as a Cake Tool

Utils Class

The Utils class provides a collection of static utility methods for working with files and directories.

Methods

IsNullOrEmpty

public static bool IsNullOrEmpty(string fileName)

Determines whether the specified file exists and has a length greater than zero.

  • fileName: The name of the file to check.

Returns true if the file exists and has a length greater than zero; otherwise, false.

ReadAllTextAsync

public static async Task<string> ReadAllTextAsync(string path, Encoding? encoding = null)

Asynchronously reads the entire contents of a text file and returns the result as a string.

  • path: The path to the file to read.
  • encoding: The encoding to use when reading the file. If null, the default encoding for the operating system is used.

Returns a Task representing the completion of the file read operation. The result is the contents of the file as a string.

ResetFile

public static string ResetFile(params string[] paths)

Resets the contents of the specified files by overwriting them with an empty string.

  • paths: The paths of the files to reset.

Returns a string containing the path(s) of the file(s) that were reset.

ResetDirectory

public static string ResetDirectory(params string[] paths)

Determines whether the specified directories exists and create new, empty directories in their place if not.

  • paths: The paths of the directories to reset.

Returns a string containing the path(s) of the directory(s) that were reset.

WriteAllText

public static async Task<string> WriteAllText(string path, string content, Encoding? encoding = null)

Writes the specified content to a file at the specified path. If the file does not exist, it is created; otherwise, its contents are overwritten.

  • path: The path of the file to write to.
  • content: The content to write to the file.
  • encoding: The character encoding to use when writing the file. If not specified, the default encoding is used.

Returns a task representing the asynchronous write operation.

Example Usage

using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        // Check if file exists and has a length greater than zero
        bool fileExistsAndNotEmpty = Utils.IsNullOrEmpty("example.txt");

        // Read the entire contents of a text file as a string
        string fileContents = await Utils.ReadAllTextAsync("example.txt", Encoding.UTF8);

        // Reset the contents of a file
        string resetFilePath = Utils.ResetFile("example.txt");

        // Reset the contents of a directory
        string resetDirectoryPath = Utils.ResetDirectory("example_directory");

        // Write text to a file
        await Utils.WriteAllText("example.txt", "Hello, world!", Encoding.UTF8);
    }
}
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Czlovek.Files:

Package Downloads
Czlovek.Security

A collection of methods for generating, hashing, and encrypting data.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0-beta.82 73 3/20/2026
2.1.0-beta.81 57 2/21/2026
2.1.0-beta.80 63 2/21/2026
2.1.0-beta.79 67 2/13/2026
2.1.0-beta.78 70 2/11/2026
2.1.0-beta.77 57 2/11/2026
2.1.0-beta.76 63 2/10/2026
2.1.0-beta.75 61 2/10/2026
2.1.0-beta.74 69 1/28/2026
2.1.0-beta.73 193 11/6/2025
2.1.0-beta.72 162 11/6/2025
2.1.0-beta.71 176 11/4/2025
2.1.0-beta.70 170 11/4/2025
2.1.0-beta.69 174 11/4/2025
2.1.0-beta.68 177 11/4/2025
2.1.0-beta.67 177 11/2/2025
2.1.0-beta.66 182 11/2/2025
2.1.0-beta.65 106 11/1/2025
2.1.0-beta.64 105 11/1/2025
1.0.10 525 4/11/2023
Loading failed