I have a class:
public class PicDetailsClass : ISerializable
{
public string Exif_Image_Make { get; set; }
public string Exif_Image_Model { get; set; }
public string Exif_Image_Orientation { get; set;
.....(there are over 200 different strings I want to store in this class)
}
Then I have a text file with the following data:
Exif.Image.Make,ASCII,NIKOND
Exif.Image.Model,ASCII,D5100
...
What I want to do is read the text file, based on the first column (Exif.Image.Make or whatever it is), I want to then store the data from column 3 in the form that is stated in column 2 (ASCII) to a list which I could ultimitly store in a XML or SQL.
I've got the part down where I have created the class like my example above and now reading through the text file line by line, I am able to store each column in a array but not sure how to now store those in a list without doing it one by one using if statements
using (StreamReader reader = new StreamReader(File))
{
string line;
PicDetailsClass Details = new PicDetailsClass();
while ((line = reader.ReadLine()) != null)
{
string allText = Regex.Replace(line, @"\s+", ",");
string[] myString = Regex.Replace(line, @"\s+", ",").Split(',');
foreach (string column in myString)
{
string Type = myString[0];
if (Type == "Exif.Image.Make")
{
Details.Exif_Image_Make = myString[3];
}
}
}
reader.Close();
}