AsyncIO is easy-to-use .NET library for common async IO file system operations. Implemented operations are fully asynchronous and do not use threads from thread pool.
AsyncIO provides decent control over async execution (e.g. support of CancellationToken
) and provides API for specifying Encoding
.
You can install AsyncIO from nuget.
Also, you can download compiled dll from the releases page.
AsyncIO is very easy to use especially if you used System.IO.File
. There is a static class AsyncFile
to access all supported async io operations.
You can also use extension methods for System.IO.FileInfo
.
- Read text from file
var text = await AsyncFile.ReadAllTextAsync("path_to_file");
- Read text from file with Encoding
var text = await AsyncFile.ReadAllTextAsync("path_to_file", Encoding.UTF8);
- CancellationToken usage
var tokenSource = new CancellationTokenSource();
try
{
var moveTask = AsyncFile.MoveAsync("file_source_path", "file_destination_path", tokenSource.Token);
tokenSource.Cancel();
await moveTask;
}
catch (OperationCancelledException e)
{
// Handle cancellation here.
}
System.IO.FileInfo
extension method usage
var fileInfo = new FileInfo("path_to_file");
var text = await fileInfo.ReadAllTextAsync("path_to_file");
- AppendAllLinesAsync
- AppendAllTextAsync
- CopyAsync
- DeleteAsync
- MoveAsync
- ReadAllBytesAsync
- ReadAllLinesAsync
- ReadAllTextAsync
- WriteAllBytesAsync
- WriteAllLinesAsync
- WriteAllTextAsync
- Feel free to submit issues with or request new features via GitHub Issues.
- Before asking questions about library usage, please verify that it isn't covered in Usage section.
- Before creating new pull request, please create a ticket for it.
Library is distributing under the MIT license. You can see details here.
- Implement async analog of
File.Replace
method.