-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileOperation.cs
More file actions
49 lines (41 loc) · 1.12 KB
/
FileOperation.cs
File metadata and controls
49 lines (41 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.IO;
using System.Reflection;
/*
* C# file stram class provide a stream for file opearation,
* It can be used to perform synchronus and ascynoius read write Opearioon Haweli .
*
*/
namespace ConsoleApp76
{
internal class Program
{
public static void Main(string[] args)
{
const string path = @"C:\Users\Harshal\Desktop\Program\Test.txt";
if (!File.Exists(path))
return;
var fsm = new FileStream(path,FileMode.Create);
var sw = new StreamWriter(fsm);
sw.WriteLine("Hello Harshal Raverkar");
sw.Close();
fsm.Close();
var fpm = new FileStream(path,FileMode.OpenOrCreate);
var sr = new StreamReader(fpm);
var s = sr.ReadLine();
Console.WriteLine(s);
fpm.Close();
sr.Close();
using (TextWriter tw = File.CreateText(path))
{
tw.WriteLine("Hello Rajesh Bhai How are you");
tw.WriteLine("Te");
tw.Close();
}
using (TextReader tr = File.OpenText(path))
{
Console.WriteLine(tr.ReadToEnd());
}
}
}
}