Reputation: 1
I have a new task I want to store every student data in a separate text file..
id name subject marks toal subjects
1 jhone math 60 3
2 smith science 50 3
3 clark math 90 3
1 jhone science 80 3
3 clark science 56 3
1 jhone ecnomics 75 3
2 smith math 40 3
3 clark ecnomics 99 3
like this: filename = 1 jhone
and data in file is
1 jhone math 60 3
1 jhone science 80 3
1 jhone ecnomics 75 3
2nd filename = 2 smith
and data in file is
2 smith science 50 3
2 smith math 40 3
3rd filename = 3 clark
and data is
3 clark math 90 3
3 clark science 56 3
3 clark ecnomics 99 3
Now what I want when total subject = total records then result store in a another text
file name is finalResult
like this
1,jhone,math 60,science 80,ecnomics 75
3,clark,math 90,science 56,ecnomics 99
and both files name = 1 jhone
and filename = 3 clark
both are automatically deleted
Upvotes: 0
Views: 244
Reputation: 1910
Hint: use: Directory.GetFiles
to get the files, use File.ReadAllLines
to read all the lines into a string[], the String.Split
to split the lines...
Upvotes: 0
Reputation: 3778
I would advice you to save it on HD as XML text file.
I think you are using C#:
XmlDocument xml = new XmlDocument();
XmlElement xmlStudent = xml .CreateElement("Student");
xmlmetaData.AppendChild(xmlStudent);
XmlElement xmlFirstTagElement = xml.CreateElement("FirstTag");
xmlFirstTagElement .InnerText = "YOUR VALUE";
xmlStudent .AppendChild(xmlFirstTagElement);
//SAVE ON DISK
xml.Save("Path");
Upvotes: 1