Skip to main content

Posts

Showing posts from September, 2020

FileInfo class in C#

FileInfo class in C# FileInfo  is a class of  System.IO   namespace  and it is useful to perform file operations such as create, read, delete, rename, moving, opening and appending to files. The  FileInfo  class will provide the same functionality as  File  class to manipulate the files but if we are performing multiple operations on the single file, then it’s more efficient to use  FileInfo  class methods instead of  File  class methods. FileInfo  class is having a different type of  properties  and  methods  to perform operations on files. FileInfo Properties The following are the different type of properties which are provided by the FileInfo class to retrieve the information about files.   Property Description Directory This property will return an instance of the parent directory of a file. DirectoryName It is...

FileStream in C#

  FileStream in C# Explained FileStream  in system.io namespace provides a  Stream  for a file, supporting both synchronous and asynchronous read and write operations. A stream is a flow of data from a source into a destination. The source or destination can be a disk, memory, socket, or other programs. When we use  FileStream , we work with bytes. For more convenient work with text data, we can use  StreamWriter  and  StreamReader . Writing text using   FileStream in C# In the following example, we write text data into a file with  FileStream . using System; using System.IO; using System.Text;   namespace WriteText {     class Program     {         static void Main( string [] args)         {             var fileName = @"C:\Users\Csharpnaija\Do...