using System;
using System.IO;
using System.Text;
class Demo
{
public static void Main()
{
string filepath= @"d:\raj\emo.txt";
using (FileStream fs = File.Create(filepath))
{
Byte[] info = new UTF8Encoding(true).GetBytes("File is Created Successfully");
fs.Write(info, 0, info.Length);
}
using (StreamReader sr = File.OpenText(filepath))
{
string x = "";
while ((x = sr.ReadLine()) != null)
{
Console.WriteLine(x);
}
}
Console.Read();
}
}
---------------------
OUTPUT:-
File is Created Successfully
-------------------------------------------
using System.IO;
using System.Text;
class Demo
{
public static void Main()
{
string filepath= @"d:\raj\emo.txt";
using (FileStream fs = File.Create(filepath))
{
Byte[] info = new UTF8Encoding(true).GetBytes("File is Created Successfully");
fs.Write(info, 0, info.Length);
}
using (StreamReader sr = File.OpenText(filepath))
{
string x = "";
while ((x = sr.ReadLine()) != null)
{
Console.WriteLine(x);
}
}
Console.Read();
}
}
---------------------
OUTPUT:-
File is Created Successfully
-------------------------------------------
No comments:
Post a Comment