Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukas9812/filewriter
Project enables to save files with predefined custom name and its maximal size in MB. If this size is exceeded a new file with increment index is created.
https://github.com/lukas9812/filewriter
files filesystem size-optimization
Last synced: 11 days ago
JSON representation
Project enables to save files with predefined custom name and its maximal size in MB. If this size is exceeded a new file with increment index is created.
- Host: GitHub
- URL: https://github.com/lukas9812/filewriter
- Owner: lukas9812
- Created: 2024-07-25T19:37:24.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-15T07:38:42.000Z (3 months ago)
- Last Synced: 2024-10-31T08:15:32.612Z (19 days ago)
- Topics: files, filesystem, size-optimization
- Language: C#
- Homepage:
- Size: 546 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NuGet usage:
NuGet: https://www.nuget.org/packages/RollingFileWriter
1. Reference NuGet package via using in your class:
```cs
using RollingFileWriter;
```
2. Choose among default or parameter constructor- **Default ctor:** Path is automatically set to "StoredData/Data_{DateTime.Today:dd_MM_yyyy}" and maximal file size is set to 500 MB. Values are not possible to configure.
```cs
public RollingFileWriterService()
{
_maximalFileSizeInMb = 500;
Directory.CreateDirectory(_directoryPath);
SetupFileName(string.Empty);
}
```
- **Parameter ctor:** Fully configurable values. If you'll not fill last parameter **maximalFileSizeInMb** maximal file size will be automatically set to 500 MB.
```cs
public RollingFileWriterService(string directoryPath, string fileName, int maximalFileSizeInMb = 500)
{
_maximalFileSizeInMb = maximalFileSizeInMb;
_directoryPath = directoryPath;
Directory.CreateDirectory(_directoryPath);
SetupFileName(fileName);
}
```
3. From created instance call method with incoming parameter as string or object:```cs
WriteData(string data)
```
OR```cs
WriteData(object dataAsObject)
```4. All written data you can find in **/bin** folder under mentioned folder name.
# Whole solution structure
The aim of this project is to develop an application that saves files with a preset size limit, specified in the appsettings.json file. If a file exceeds this size limit (in MB), a new file will be created with an incremented index added to the end of the file name (e.g., Data_26_07_2024_1, Data_26_07_2024_2, etc.).
Additionally, the application offers the option to filter specific properties to prevent the storage of unnecessary data.
Architecture:
![image](https://github.com/user-attachments/assets/fa4ceab9-82f8-425f-a362-0120d88e9dc9)