Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileSystem CLI - C#

A command-line file management utility built with C# and .NET.

This project provides a simple CLI for working with local files. It was built to practice C# file-system operations, classes, methods, path handling, and resource management through a small, structured application.

Features

  • Create new files
  • Select an existing working file
  • Read file contents
  • Overwrite file contents
  • Append data to a file
  • Delete files
  • Prevent deletion of the currently active working file
  • Protect data.txt as a permanent file
  • Automatically work with files inside the project's Files directory
  • Separate file operations into dedicated classes

Project Structure

FileSystem CLI - C#
│
├── Operations/
│   ├── File_creator.cs
│   ├── File_deleter.cs
│   ├── File_selector.cs
│   ├── file_Writer.cs
│   └── Reader.cs
│
├── Files/
│   └── data.txt
│
├── Program.cs
├── FileSystem CLI - C#.csproj
├── .gitignore
├── README.md
│
├── bin/          # Build output
└── obj/          # Intermediate build files

bin/ and obj/ are generated by .NET and should not be committed to the repository.

Components

Program.cs

Handles the main application flow, menu, user input, and calls the appropriate file operation.

File_creator.cs

Creates new files inside the Files directory.

File_selector.cs

Allows the user to create a new file or select an existing file as the current working file.

Reader.cs

Reads and displays the contents of the selected file using StreamReader.

file_Writer.cs

Handles both:

  • Overwriting existing file content
  • Appending new content

It uses StreamWriter.

File_deleter.cs

Handles file deletion while applying the project's deletion rules:

  • The current working file cannot be deleted.
  • data.txt cannot be deleted.
  • A file must exist before it can be deleted.

File Rules

The application keeps files inside:

Files/

Permanent File

data.txt is treated as the permanent file and cannot be deleted.

Current Working File

The currently selected working file cannot be deleted. This prevents the application from removing the file that is currently being used.

Menu

The application provides the following operations:

<--- File Manager --->

1. Create another file
2. Read the working file
3. Overwrite working file
4. Append data to working file
5. Delete working file
6. Change the Working File
7. Exit

Technologies

  • C#
  • .NET
  • System.IO
  • File
  • Directory
  • Path
  • StreamReader
  • StreamWriter

C# Concepts Practiced

This project focuses on practical C# fundamentals:

  • Classes and objects
  • Methods
  • if statements
  • switch statements
  • Loops
  • Arrays
  • String handling
  • Nullable values
  • TryParse
  • File handling
  • Directory handling
  • Path handling
  • using statements
  • Resource disposal
  • Multiple source files
  • Separation of responsibilities

Getting Started

Prerequisites

Install the .NET SDK.

Check your installed version:

dotnet --version

Clone the Repository

git clone <your-repository-url>

Move into the project directory:

cd FileSystem-CLI

Run the Project

dotnet run

Example File Structure

After creating additional files, the Files directory may look like:

Files/
├── data.txt
├── notes.txt
└── project.txt

The application can then select these files and perform the supported operations through the CLI.

Design

The project separates responsibilities into individual classes:

Program
   │
   ├── File_creator
   ├── File_selector
   ├── Reader
   ├── file_Writer
   └── File_deleter

This keeps Program.cs focused on application flow while individual classes handle specific file operations.

Future Improvements

Possible future additions:

  • Rename files
  • Copy files
  • Move files
  • Display file size
  • Display file creation and modification dates
  • Search files
  • Create directories
  • Delete directories
  • Add confirmation before deleting files
  • Improve CLI navigation

License

This project is intended for educational and personal use.

About

A modular C#/.NET command-line file management application implementing structured local file-system operations with System.IO, resource management, validation, and separated responsibilities.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages