-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatedFileClass.cs
65 lines (62 loc) · 2.01 KB
/
updatedFileClass.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
/* Gavin Rodgers
* 3309 ATM Project
* This class handles and stores all the information for the updated file class
* Last edited: 10/13/18
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ATM
{
public class updatedFileClass
{
private string updatedFilePath;
private System.IO.StreamWriter updatedFileSW; // Reference variable of type SR
private int recordWrittenCount;
//creates the constructor to bring in the path to the updated file
public updatedFileClass(string filePath)
{
recordWrittenCount = 0;
updatedFilePath = filePath;
try
{
updatedFileSW = new System.IO.StreamWriter(updatedFilePath);
}
catch (Exception ex)
{
MessageBox.Show("Cannot open file" + updatedFilePath + "Terminate Program.",
"Output File Connection Error.",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
} // end Try
}
//gets amount of records written out to updated file
public int getRecordsWrittenCount()
{
return recordWrittenCount;
}
//writes out the next record to the updated file
public void putNextRecord(string nextRecord)
{
try
{
updatedFileSW.WriteLine(nextRecord);
}
catch { MessageBox.Show("Record didnt write to file", "File Error"); }
recordWrittenCount++;
}
//closes the updated file
public void closeFile()
{
updatedFileSW.Close();
}
//rewinds the updated file
public void rewindFile()
{
recordWrittenCount = 0;
updatedFileSW.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
}
}
}