Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/conesoft/nuget-files
tiny wrapper around System.IO to make life easier
https://github.com/conesoft/nuget-files
dotnet-core library
Last synced: 14 days ago
JSON representation
tiny wrapper around System.IO to make life easier
- Host: GitHub
- URL: https://github.com/conesoft/nuget-files
- Owner: conesoft
- License: mit
- Created: 2020-05-02T21:19:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-23T00:14:35.000Z (8 months ago)
- Last Synced: 2024-05-23T00:30:49.833Z (8 months ago)
- Topics: dotnet-core, library
- Language: C#
- Homepage:
- Size: 121 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Conesoft.Files
[![publish to nuget](https://github.com/conesoft/files/actions/workflows/publish.yml/badge.svg)](https://github.com/conesoft/files/actions/workflows/publish.yml)
[![NuGet version (Conesoft.Files)](https://img.shields.io/nuget/v/Conesoft.Files.svg?style=flat-square)](https://www.nuget.org/packages/Conesoft.Files/)
https://www.nuget.org/packages/Conesoft.Files/## tiny example
adapted from realworld use
```csharp
var logfile = Directory.From("SomeRoot") / "Scheduler" / Filename.From(DateTime.Today.ToShortDateString(), "md");await logfile.AppendText($"- **{task.GetType().Name}** *executed* ");
```instead of
```csharp
var logPath = System.IO.Path.Combine("SomeRoot", "Scheduler", $"{DateTime.Today.ToShortDateString()}.md");
await System.IO.File.AppendAllTextAsync(logPath, $"- **{task.GetType().Name}** *executed* ");
```## reading/writing objects
```csharp
var data = await File.From("some\path.json").ReadFromJson();File.From("some\other path.json").WriteAsJson(data);
```## temporary directories
```csharp
{
using var temp = Directory.Common.Temporary();
await (temp / Filename.From("some temporary", "tmp")).WriteBytes(somebytes);
// temporary directory gets deleted when out of scope
}
```## watching a folder
```csharp
void PrettyPrint(string title, File[] files)
{
if(files.Length > 0)
{
Console.WriteLine($"{title} ({files.Length})");
foreach(var file in files)
{
Console.WriteLine(file);
}
Console.WriteLine();
}
}await foreach(var files in Directory.From("some\path"))
{
PrettyPrint("ALL FILES", files.All);
PrettyPrint("ADDED FILES", files.Added);
PrettyPrint("CHANGED FILES", files.Changed);
PrettyPrint("DELETED FILES", files.Deleted);
}
```