File Management - C# Programming Exercises

Explore File Management in C# with our hands-on exercises! Learn to create, read, write, and manage files in your applications. These lessons are perfect for gaining practical experience with file handling in C#. Enhance your skills today!

  •  Writing to a text file

    In this exercise of C#, you need to create a program that asks the user for several sentences (until they just press Enter without typing anything) and stores those s...

  •  Appending to a text file

    In this exercise of C#, you need to create a program that asks the user for several sentences (until they just press Enter without typing anything) and stores those s...

  •  Display file contents

    In this exercise of C#, you need to create a program that displays all the contents of a text file on the screen. The file name will either be entered via the command...

  •  Extended TextToHTML (files)

    In this exercise of C#, you need to expand the TextToHtml class so that it can dump its result to a text file. You should create a ToFile method that ta...

  •  Logger

    In this exercise of C#, you need to create a Logger class with a static Write method, which will append a certain text to a log file. The method should ...

  •  More

    In this exercise of C#, you need to create a program that behaves like the Unix "more" command. The program should display the contents of a text file and prom...

  •  Text replacer

    In this exercise of C#, you need to create a program to replace words in a text file, saving the result into a new file. The program should take as parameters the fil...

  •  Count letters in a file

    In this exercise of C#, you need to create a program to count how many times a specific character appears inside a file of any kind. The file and the letter to search...

  •  Reading a binary file (1: BMP)

    In this exercise of C#, you need to create a program that checks if a BMP image file seems to be correct. The program must verify if the first two bytes of the file ...

  •  Writing to a binary file

    In this exercise of C#, you need to create a program that asks the user for their name, age (as a byte), and the year they were born (as an int), and st...

  •  C# to Java

    In this exercise of C#, you need to create a basic C# to Java translator. The program should accept C# source files and generate an equivalent ...

  •  Invert a text file

    This C# exercise aims to teach how to manipulate text files and reverse their content using basic programming structures. In this exercise, you need to create ...

  •  Reading a binay file (2 - GIF)

    This C# exercise aims to teach how to check the validity of a GIF image file. In this exercise, you need to create a program that reads the first four bytes of...

  •  Friends database, using files

    This C# exercise aims to expand a friends database by allowing data to be loaded from a file at the beginning of each session and saved to...

  •  Pascal to C# translator

    This C# exercise involves creating a basic Pascal to C# translator. The program should accept code written in Pascal and convert it to an equival...

  •  Convert a text file to uppercase

    This C# exercise involves creating a program that reads a text file and dumps its content into another file, making a transformation in the process. The transformatio...

  •  Convert any file to uppercase

    This C# exercise involves creating a program that reads a file of any kind and dumps its content into another file, applying a transformation in the process. The tran...

  •  File inverter

    This C# exercise involves creating a program to "invert" a file. The program must take an original file and create a new one with the same name but with the ".inv" ex...

  •  File encrypter

    This C# exercise involves creating a program to encrypt a text file into another text file. The program should be able to read the content of a text file, apply an en...

  •  Count words

    This C# exercise involves creating a program to count the number of words stored in a text file. The program should read the content of a text file, process it, and c...

  •  BMP width and height, BinaryReader

    This C# exercise involves creating a program to display the width and height of a BMP file using a BinaryReader. The program should read the BMP file header an...

  •  TXT to HTML translator

    This C# exercise involves creating a "Text to HTML converter". The program should read a source text file and create an HTML file from its contents. The destination f...

  •  Invert binary file V2

    This C# exercise involves creating a program to "invert" a file using a FileStream. The program should create a file with the same name as the original file, b...

  •  BMP width & height, FileStream

    This C# exercise involves creating a program that reads a BMP file using a FileStream and displays its width and height. The BMP format has a spe...

  •  File copier

    This C# exercise involves creating a program that copies a source file to a destination file using a FileStream and a block size of 512 KB. The program should ...

  •  MP3 reader

    This C# exercise is about the ID3 specifications, which apply to any file or audiovisual container, but are primarily used with audio containers. There are three comp...

  •  C to C# converter

    This exercise consists of creating a program that converts simple C programs, such as the following one, into C#, ensuring that the resulting program compiles ...

  •  File splitter

    This exercise involves creating a program that splits a file (of any kind) into pieces of a certain size. The program should receive the file name and the desired size of th...

  •  Encrypt a BMP file

    This exercise involves creating a program to encrypt and decrypt a BMP image file by changing the "BM" mark in the first two bytes to "MB" and vice versa. The program should...

  •  CSV converter

    This exercise involves creating a program that reads a CSV file with four data blocks (three text fields and one numeric) separated by commas, and generates a text file wher...

  •  File comparer

    This exercise involves creating a C# program that determines if two files (of any kind) are identical, meaning they have the same content. The program should c...

  •  Display BPM on console

    This exercise involves creating a C# program to decode an image file in the Netpbm format (specifically, the P1 format, which is for black and white ima...

  •  PCX width and height

    This exercise involves creating a C# program to check if a file is a PCX image and, if so, extract and display the image's dimensions (width and height). To do...

  •  Extract text from a binary file

    This exercise involves creating a C# program that extracts only the alphabetic characters contained in a binary file and dumps them to a separate file. The program sh...

  •  C# to Pascal converter

    This exercise involves creating a C# program that converts simple C# programs to their equivalent in the Pascal language. The program should read C# cod...

  •  Dump

    This exercise involves creating a "dump" utility: a hex viewer that displays the contents of a file, with 16 bytes per row and 24 rows per screen. The program should pause a...

  •  DBF extractor

    This exercise involves creating a program that displays the list of fields stored in a DBF file. The DBF format is used by the old dBase database manager and is still suppor...

  •  Text censorer

    This exercise involves creating a program to censor text files. The program should read a text file and output its contents to a new file, replacing certain words with "[CEN...

  •  SQL to text

    In this exercise, you need to create a C# program capable of parsing SQL INSERT commands and extracting their data into separate lines of text. The program should pro...

  •  PGM viewer

    The PGM format is one of the versions of the NetPBM image formats. Specifically, it is the variant capable of handling images in shades of gray. Its header starts with a line conta...

  •  Display BMP on console V2

    In this exercise, you are asked to develop a program in C# that can display a 72x24 BMP file on the console. To do this, you must use the information contained...

 More C# Programming Exercises Grouped

  •  First contact with C# Sharp

    Explore our set of C# programming exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of C#. From variables and data types to control structures and s...

  •  Flow Control

    Explore our curated collection of Flow Control C# Programming Exercises! Designed to strengthen your understanding and mastery of flow control structures in C#, these exercises offer a hands-on approach to learning. From...

  •  Basic Data Types

    Explore our comprehensive collection of Basic Data Types C# Programming Exercises! Designed to provide hands-on practice with fundamental data types in C#, these exercises are perfect for beginners looking to solidify th...

  •  Arrays, Structures and Strings

    Explore our curated selection of Arrays, Structures, and Strings C# Programming Exercises! Tailored to provide practical experience with essential data structures and string manipulation in C#, these exercises offer a dy...

  •  Functions

    Embark on a journey of learning with our Functions C# Programming Exercises! Tailored for beginners, these exercises offer a hands-on approach to mastering the art of functions in C#. From understanding the basics of fun...

  •  OOP Object Oriented Programming

    Unlock the power of Object-Oriented Programming (OOP) with our C# exercises! These lessons cover classes, objects, and core principles like inheritance and polymorphism. Perfect for beginners, each exercise offers a hand...

  •  OOP More On Classes

    Dive deeper into Object-Oriented Programming with our advanced C# exercises! This section explores advanced class features, interfaces, and more. Whether you're reinforcing your OOP skills or preparing for complex projec...

  •  Object Persistence

    Master the art of Object Persistence in C#! These exercises focus on saving and retrieving objects, helping you build applications that store data effectively. Perfect for learners ready to explore advanced storage techn...

  •  Access To Relational Databases

    Delve into Access to Relational Databases in C#! These exercises provide practical experience connecting to and working with databases like SQL Server. Learn to execute queries, manage data, and integrate database functi...

  •  Dynamic Memory Management

    Learn Dynamic Memory Management in C#! These exercises guide you through concepts like pointers and memory allocation, crucial for building efficient applications. Develop a deeper understanding of how C# manages memory ...

  •  Additional Libraries

    Discover Additional Libraries in C#! These exercises introduce libraries that expand the capabilities of your C# applications. From working with collections to threading and beyond, these lessons will elevate your progra...

 Maybe you will be interested in these C# Programming Exercises

  •  Table + array + files

    In this exercise, you are asked to expand the previous exercise (tables + array) by adding two new methods. The first of these methods should handle dumping the array...

  •  Table + SetOfTables + files

    In this exercise, you are asked to expand the previous exercise (tables + array + files) by creating three new classes: Table, SetOfTab...

  •  Insects + persistence

    In this exercise, you need to create a new version of the insects exercise where the data is persisted using some form of storage, such as a database or...

  •  Cities - persistence

    In this exercise, you need to create a new version of the cities database, using persistence to store its data instead of text files. The goal of this exercise...