SEARCH C# PROGRAMMING CODES HERE

Stream Writer

Stream Writer in C#
C# Stream Writer class is utilized to compose characters to a stream in explicit encoding. It acquires the TextWriter class. It gives over-burden compose() and writeln() strategies to compose information into the record. So let's Understand through the program in which we will create a function to write some text as Rohit Programming zone and we will save it as File.txt in the computer f:// drive location and also once the file is created message appears on the user screen, So to perform this task we have to use Stream Writer class which belongs to the System.IO Namespace. simply copy the yellow highlighted code as follows.
Program

using System;
using System.IO;

namespace program
{
    class Program
    {
        static void Main(string[] args)
        {
            FileStream fs = new FileStream("d:\\File.txt", FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);

            sw.WriteLine("Rohit Programming zone");
            sw.Close();
            fs.Close();
            Console.WriteLine("File Saved");
            Console.ReadKey();
           }       
    }
 }

Output
File Saved

Now go to the f:// Drive section and search for File.txt and then open the file and see the text is saved as Rohit Programming zone.