-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClsTxtFileIO.cs
75 lines (60 loc) · 1.85 KB
/
ClsTxtFileIO.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
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ProofConceptFinalProj
{
public class ClsTxtFileIO
{
private StreamReader streamIn;
protected int mNumRecordsRead = 0;
public int RecordsRead
{
get
{
return mNumRecordsRead;
}
set
{
if(value==0)
{
mNumRecordsRead = value;
}
}
}
public void AppendRecords(string pFName, string pLName, string pDept, string pPhone, string pSalary, string pDays)
{
StreamWriter StreamOut = File.AppendText(@"EmpData.txt");
StreamOut.WriteLine(pFName + " " + pLName + " " + pDept +" " + pPhone + " " + pSalary + " " + pDays);
StreamOut.Flush();
StreamOut.Close();
}
public void OverWriteRecords(string pFName, string pLName, string pDept, string pPhone)
{
StreamWriter StreamOut = File.CreateText(@"EmpData.txt");
StreamOut.WriteLine(pFName + " " + pLName + " " + pDept + " " + pPhone);
StreamOut.Flush();
StreamOut.Close();
}
public void OpenForRead()
{
streamIn = File.OpenText(@"EmpData.txt");
}
public string ReadRecord()
{
mNumRecordsRead++;
return streamIn.ReadLine();
}
public void CloseForRead()
{
streamIn.Close();
}
public void CreateFile()
{
StreamWriter StreamOut = File.CreateText(@"EmpData.txt");
StreamOut.Close();
}
}
}