PupaLib.FileIO
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package PupaLib.FileIO --version 1.0.1
NuGet\Install-Package PupaLib.FileIO -Version 1.0.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="PupaLib.FileIO" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PupaLib.FileIO" Version="1.0.1" />
<PackageReference Include="PupaLib.FileIO" />
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 PupaLib.FileIO --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PupaLib.FileIO, 1.0.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.
#:package PupaLib.FileIO@1.0.1
#: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=PupaLib.FileIO&version=1.0.1
#tool nuget:?package=PupaLib.FileIO&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
๐งช๏ธ PupaLib.FileIO
PupaLib.FileIO is an incredibly simple library for working with files and folders. ๐ฏ
๐๏ธ Key Features
| ๐ Feature | ๐ Description |
|---|---|
| Easy to Use | Simplifies file manipulation tasks ๐ ๏ธ |
| Versatile Functionality | - Create new files and folders ๐<br>- Read and write data efficiently ๐ |
| Cross-Platform Support | Works seamlessly across different operating systems ๐ |
| Lightweight | Minimal impact on performance โก |
๐ Installation
You can install the package through the NuGet Package Manager or via the command line
dotnet add package PupaLib.FileIO
Or through the NuGet Package Manager
Install-Package PupaLib.FileIO
๐ก Usage
๐ ๏ธ File or Folder Creation
Create a file:
var path = "./path/file_name.txt";
var file = VirtualFile.CreateFile(path);
Create a folder:
var path = "./path/folder_name";
var folder = VirtualFile.CreateFolder(path);
๐ Check If File or Folder Exists
Check for a file:
var path = "./path/file_name.txt";
var file = VirtualFile.GetFile(path);
if(file is not null) {
Console.WriteLine($"File exists, path -> {file.MyPath}");
} else {
Console.WriteLine($"File not exists")
}
Check for a folder:
var path = "./path/folder_name";
var folder = VirtualFolder.GetFolder(path);
if(folder is not null) {
Console.WriteLine($"Folder exists, path -> {folder.MyPath}");
} else {
Console.WriteLine($"Folder not exists")
}
๐ Write and Read Files
Writing to a text file:
var fileName = "file.txt";
var file = VirtualIo.RootFolder.GetFileIn(fileName);
if(file is not null) {
var content = "Hello world!";
await file.WriteStringAsync(content); // Write file
Console.WriteLine($"Writes content [{content}] in file");
Console.WriteLine($"File content: {await file.ReadStringAsync()}"); //Read file
Console.WriteLine(file.GetInfo());
}
Writing with serialization:
var fileName = "file.txt";
var file = VirtualIo.RootFolder.GetFileIn(fileName);
if(file is not null) {
var content = new ExampleObject("Name", "Lastname", [12, 53, 47]);
file.WriteTContent<ExampleObject>(content, new JsonSystemSerializer()); // Write and serialize file
Console.WriteLine($"Writes content [\n{content}\n] in file");
Console.WriteLine($"File content: {file.ReadTContent<ExampleObject>(new JsonSystemSerializer())}"); //Read and deserialize file
Console.WriteLine(file.GetInfo());
}
๐๏ธ Delete File and Folder
Deleting a file:
var fileName = "file.txt";
var file = VirtualIo.RootFolder.GetFileIn(fileName);
if(file is not null) {
file.DeleteMe(); // Delete file
Console.WriteLine($"File deleted, exists: {file.Exists}");
}
Deleting a folder:
var folderName = "folder";
var folder = VirtualIo.RootFolder.GetFolderIn(folderName);
if(folder is not null) {
folder.DeleteMe(); //Delete folder
Console.WriteLine($"Folder deleted, exists: {folder.Exists}");
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PupaLib.FileIO:
| Package | Downloads |
|---|---|
|
PupaMVCF.Framework
Simplify MVC web framework on csharp |
GitHub repositories
This package is not used by any popular GitHub repositories.