using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication21
{
class Program
{
static void Main(string[] args)
{
FileStream F = new FileStream(@"C:\Users\salman\Desktop\FILE\salman.txt",FileMode.OpenOrCreate);
Console.WriteLine("Enter the text :");
string s = Console.ReadLine();
byte[] ascii = Encoding.ASCII.GetBytes(s);
foreach (byte item in ascii)
{
F.WriteByte(item);
}
Console.WriteLine("Data successfully written in file named as salman.txt");
F.Close();
Console.WriteLine("Press any key to read the same file............");
Console.ReadKey();
FileStream F2 = new FileStream(@"C:\Users\salman\Desktop\FILE\salman.txt", FileMode.OpenOrCreate);
Console.ForegroundColor = System.ConsoleColor.Green;
int i = 0;
while ((i=F2.ReadByte())!=-1)
{
Console.Write((char)i);
}
Console.ReadKey();
F2.Close();
}
}
}