Skip to content

dmustimenko/FileGenerator

Repository files navigation

File Generator

Overview

A .NET 8 console application for generating large text files. It supports sequential or partitioned generation, configurable output size, content values, batching and optional memory metrics.

Line Format

{Id}. {Text}

Requirements

  • .NET SDK 8.0+
  • OS: Windows, Linux, or macOS

Build and run

  • Restore and build all projects:

    • dotnet restore
    • dotnet build -c Release
  • Run the CLI:

    • dotnet run -c Release --project FileGenerator.Cli -- -tfs "100MB" -ofp "D:\file.txt"

Notes:

  • The double dash -- separates dotnet run options from app options.
  • Use -tfs_bytes to specify an exact byte size instead of a human-readable size.

Usage and configuration

The application binds configuration in this order (later overrides earlier):

  1. appsettings.json
  2. Command-line

Command-line switches

  • -tfs (e.g., "500MB", "1.5GB", "1024MB")
  • -tfs_bytes (e.g., 1048576)
  • -ofp (e.g., "D:\file.txt")

OutputFilePath is required.

At least one of TargetFileSize or TargetFileSizeBytes is required. TargetFileSize accepts values like "100MB", "1.5GB", "10KB" or a plain number meaning bytes. Supported units: B, KB, MB, GB.

List of Values should be provided via appsettings.json.

appsettings.json example

{
  "FileGeneration": {
    "OutputFilePath": "generatedFile.txt",
    "TargetFileSize": "512MB",
    "Values": ["alpha", "beta", "gamma"],

    "MonitorPeakMemory": true,
    "ChannelCapacity": 5000,

    "ChanceDuplicate": 5,
    "MaxId": 99999,
    "FileBatchSize": 4000,

    "IsPartitionGeneration": true,
    "PartitionCount": 4,
    "PartitionBufferSizeMb": 16,
    "PartitionFolderPath": "partitions"
  }
}

Exit codes

  • 0: Success
  • 130: Cancelled by user (Ctrl+C)
  • 2: Configuration error (invalid/missing options)
  • 1: Unexpected error

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages