Czlovek.Files
3.0.0-beta.6
See the version list below for details.
dotnet add package Czlovek.Files --version 3.0.0-beta.6
NuGet\Install-Package Czlovek.Files -Version 3.0.0-beta.6
<PackageReference Include="Czlovek.Files" Version="3.0.0-beta.6" />
<PackageVersion Include="Czlovek.Files" Version="3.0.0-beta.6" />
<PackageReference Include="Czlovek.Files" />
paket add Czlovek.Files --version 3.0.0-beta.6
#r "nuget: Czlovek.Files, 3.0.0-beta.6"
#:package Czlovek.Files@3.0.0-beta.6
#addin nuget:?package=Czlovek.Files&version=3.0.0-beta.6&prerelease
#tool nuget:?package=Czlovek.Files&version=3.0.0-beta.6&prerelease
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 | Versions 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. |
-
net10.0
- Microsoft.Extensions.Logging (>= 10.0.12)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Czlovek.Files:
| Package | Downloads |
|---|---|
|
Czlovek.Security
Salt generation, PBKDF2 password hashing and verification, SHA-256/MD5 hashing and RSA PEM loading. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-beta.10 | 61 | 11/22/2026 |
| 3.0.0-beta.9 | 62 | 11/22/2026 |
| 3.0.0-beta.8 | 63 | 11/21/2026 |
| 3.0.0-beta.6 | 100 | 9/29/2026 |
| 3.0.0-beta.5 | 94 | 9/27/2026 |
| 3.0.0-beta.4 | 73 | 9/27/2026 |
| 3.0.0-beta.3 | 67 | 9/27/2026 |
| 3.0.0-beta.2 | 77 | 9/27/2026 |
| 3.0.0-beta.1 | 101 | 7/19/2026 |
| 2.1.0-beta.85 | 113 | 6/16/2026 |
| 2.1.0-beta.84 | 92 | 5/7/2026 |
| 2.1.0-beta.83 | 94 | 5/7/2026 |
| 2.1.0-beta.82 | 135 | 3/20/2026 |
| 2.1.0-beta.81 | 105 | 2/21/2026 |
| 2.1.0-beta.80 | 108 | 2/21/2026 |
| 2.1.0-beta.79 | 105 | 2/13/2026 |
| 2.1.0-beta.78 | 112 | 2/11/2026 |
| 2.1.0-beta.77 | 98 | 2/11/2026 |
| 2.1.0-beta.76 | 104 | 2/10/2026 |
| 1.0.10 | 625 | 4/11/2023 |