File Handling in C#

Files & Folders In C#

One of the ways of permanent storage of data is through files. A file is a collection of data stored on a secondary storage device, such as the Hard Disk. Every file has a name associated with it, such as CSITquestion.txt. The name comprises of two parts the base name (in our case ‘CSITquestion) and …

Files & Folders In C# Read More »

Stream In C#

A stream is a sequence of bytes traveling from a source to a destination over a communication medium. Streams can either be input stream or output stream. The input stream is used for reading while the output stream is used for writing.   Note: This stream concept does not just apply to files. It holds …

Stream In C# Read More »

Creating Objects In C#

Creating a DirectoryInfo or FileInfo object is very simple. The constructor takes the path to the file.   DirectoryInfo di = new DirectoryInfo(“C:\\Windows”); FileInfo fi = new FileInfo(“C:\\Windows\\Notepad.exe”);   Listing All Files in a Directory   The following code snippet lists all the files in the “C:\Windows” directory.   DirectoryInfo di = new DirectoryInfo(“C:\\Windows”); FileInfo[] …

Creating Objects In C# Read More »

Scroll to Top