I haven't made a custom class before so this might not be possible, I want to read a number of text files and store certain information about them to be used throughout my program.
class text
{
public int IDnum { get; set; }
public string file { get; set; }
public int lineNum { get; set; }
public string FileText { get; set; }
public string lineType { get; set; }
}
List<text> listOne = new List<text>();
internal void ReadFile()
{
try
{
int IDtype = 0;
foreach (string x in resultFiles)
{
using (StreamReader sr = new StreamReader(x))
{
string s;//text line
int LINECOUNT = 0;
string type = "not defined";
while ((s = sr.ReadLine()) != null)// this reads the line
{
if(s.Contains("COMPUTERNAME="))
{
type = "PC Name";
}
if (s.Contains("Original Install Date: "))
{
type = "Original Install Date";
}
if (LINECOUNT==2)
{
type = "other Date";
}
if (s.Contains("DisplayName\"="))
{
type = "Add/Remove Programs";
}
text text1 = new text { IDnum = IDtype, lineNum=LINECOUNT, file=x, FileText=s, lineType=type};
LINECOUNT++;
IDtype++;
listOne.Add(text1);
}
sr.Close();
}
}
foreach(var x in listOne)
{
MessageBox.Show(x.ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
However when I try to read the list it just returns the same value "names of program.name of class.text"
I have never built custom classes before can anyone point me to a website where I can learn more examples?
Thanks in advance for any advice :)