File and Folder Operations with C #

 


In this article, we will examine in detail the use of libraries, classes and methods for performing file and folder operations in C #. The System.IO library is used to perform all input and output operations in C #. In this respect, we need to add these namespace to our projects in order to perform folder operations such as opening-deleting-moving files, creating files, adding-deleting data in the file, reading data from the file.

Folder Operations in C#

Folder operations in C # are performed with the Directory class in System.IO namespace.

Create a folder with the CreateDirectory method:

Delete folder with Delete method:

Getting detailed information about the folder:

Move folder with Move method:

Exist method to check the existence of the folder:

File Operations in C #

Many of the methods of file operations in C # are similar to those described above for folder operations. The File class under System.IO is used to perform file operations. The following example describes the basic methods for using this class.

Create file with Create method:

Copy method file copy:

Move files with Move method:

Delete files with Delete method:

Check the Exist method to find the file:

 

 

if you have question do not forget to write from the chat button next to it or from the comment

You may also like...

1 Response

  1. zvodret iluret says:

    Lovely just what I was looking for.Thanks to the author for taking his clock time on this one.

Leave a Reply

Your email address will not be published. Required fields are marked *