-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjF.cs
60 lines (55 loc) · 1.8 KB
/
objF.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace htmlInterpreter.Components
{
public class objF : Object
{
string Path { get; set; }
string Type { get; set; }
string Name { get; set; }
string Extension { get; set; }
///<summary>
/// Returns all lines in the file as a string
///</summary>
string getAllLines()
{
string alllines = "";
using(StreamReader sr = new StreamReader(Path+Name+Extension))
{
string currentline = "";
while ((currentline = sr.ReadLine())!=null)
{// Loops though all the lines and adds them to a single string
currentline += currentline+"\n";
}
}
return alllines;
}
/// <summary>
/// Return the line with the line number corresponding to the index given
/// </summary>
/// <param name="_index">line number to be returned</param>
string getLineAtIndex(int _index)
{
using (StreamReader sr = new StreamReader(Path + Name + Extension))
{
int lineNum = 0;
while (sr.ReadLine()!=null)
{
//Checks if the index is the same as the line number
//if that is the case we return the line
if (lineNum == _index)
{
return sr.ReadLine();
}
lineNum++;
}
}
//If the index is outside the the line numbers we return string with value null
return "Null";
}
}
}