-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetFigureArray.cs
59 lines (57 loc) · 1.82 KB
/
GetFigureArray.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace HoleInTheWall
{
class GetFigureArray
{
private int lineCount = 0;
private int longestLine = 0;
private char[,] pinhole;
private char[,] pinHoleArray;
public char[,] GetPinHole(string n)
{
StreamReader streamfile = null;
string arrayline;
FileStream file = null;
try
{
file = new FileStream(n, FileMode.Open);
streamfile = new StreamReader(file, Encoding.Default);
lineCount = 0;
while ((arrayline = streamfile.ReadLine()) != null)
{
if (arrayline.Length > longestLine)
{
longestLine = arrayline.Length;
}
lineCount++;
}
streamfile.Close();
StreamReader streamPinHole;
GetWriteFile fileUtils = new GetWriteFile();
streamPinHole = fileUtils.GetFile(n);
pinhole = new char[lineCount, longestLine];
pinHoleArray = new char[lineCount, longestLine];
int j = 0;
while ((arrayline = streamPinHole.ReadLine()) != null)
{
for (int i = 0; i < arrayline.Length; i++)
{
pinHoleArray[j, i] = arrayline[i];
}
j++;
}
streamPinHole.Close();
}
catch (IOException exc)
{
Console.WriteLine("IO ERROR:\n" + exc.Message);
}
return pinHoleArray;
}
}
}