StringReader/Writer App : StreamWriter « File Directory Stream « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

  class Program
  {
    static void Main(string[] args)
    {
      using (StringWriter strWriter = new StringWriter())
      {
        strWriter.WriteLine("A");
        Console.WriteLine(strWriter);
        StringBuilder sb = strWriter.GetStringBuilder();
        sb.Insert(0, "Hey!! ");
        Console.WriteLine("-> {0}", sb.ToString());
        sb.Remove(0, "Hey!! ".Length);
        Console.WriteLine("-> {0}", sb.ToString());
        using (StringReader strReader = new StringReader(strWriter.ToString()))
        {
          string input = null;
          while ((input = strReader.ReadLine()) != null)
          {
            Console.WriteLine(input);
          }
        }
      }
    }
  }








15.21.StreamWriter
15.21.1.new StreamWriter(fs, Encoding.UTF8)
15.21.2.Reading and Writing Files
15.21.3.Open a file using StreamWriter
15.21.4.Save string, decimal and char using FileStream and StreamWriter
15.21.5.Create StringWriter from StringBuilder
15.21.6.Using StreamWriter: write string
15.21.7.Using StreamWriter: write char
15.21.8.Using StreamWriter: Writes an Array of characters
15.21.9.Using StreamWriter: write a portion of an array
15.21.10.StreamWriter/Reader App
15.21.11.StringReader/Writer App
15.21.12.Stream Write with StreamWriter
15.21.13.Using statement and StreamWriter
15.21.14.Using File.CreateText to create a text file and return StreamWriter