forked from gridtraining2018-1/trainingInterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram1.cs
63 lines (51 loc) · 1.37 KB
/
Program1.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace logfile1
{
class Program
{
static void WriteFile()
{
FileStream f;
try
{
//f = new FileStream("E:\\f.txt", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter("E:\\f.txt",true);
sw.WriteLine(DateTime.Now);
sw.WriteLine("jjjhhk");
sw.Close();
}
catch (Exception e)
{
throw(e);
}
//f.Close();
}
static void ReadFile()
{
FileStream f1;
try
{
f1= new FileStream("E:\\f.txt", FileMode.OpenOrCreate);
byte[] buffer = new byte[1024];
int byteRead = f1.Read(buffer, 0, buffer.Length);
Console.WriteLine(Encoding.ASCII.GetString(buffer, 0, byteRead));
}
catch (Exception e1)
{
throw(e1);
}
f1.Close();
}
static void Main(string[] args)
{
WriteFile();
ReadFile();
Console.ReadKey();
}
}
}