I am reading through a text file and want to break down specific blocks of text out of that text file and place it into a new text file.
in my file:
MEMBER NAME J20ASDF
//-----text-----
MEMBER NAME J15QWER
//-----text-----
MEMBER NAME J15QWER
//*Comments
//-----text-----
MEMBER NAME J15QWER
//-----text-----
MEMBER NAME K23JGKD
//-----text-----
I want to take the bolded files out and put them into the same separate file.
I have never really asked a question here before so if im missing anything i'd be glad to post that as well. Mostly here I am lost on the logic. I want to be able to make a separate text file for every member.
in my file:
MEMBER NAME J20ASDF
//-----text-----
MEMBER NAME J15QWER
//-----text-----
MEMBER NAME J15QWER
//*Comments
//-----text-----
MEMBER NAME J15QWER
//-----text-----
MEMBER NAME K23JGKD
//-----text-----
I want to take the bolded files out and put them into the same separate file.
Code:
if (txtFile.Text != "")
{
curFile = txtFile.Text;
StreamReader objReader = new StreamReader(curFile);
string sLine = "";
ArrayList arrText = new ArrayList();
while (sLine != null)
{
sLine = objReader.ReadLine();
//if line is not null
if (sLine != null)
{
//if line does not start with //* comments
if (!sLine.Contains("//*"))
{
while (member.Equals(separateJob(sLine)))
{
if (sLine.Contains("//") || sLine.Contains("MEMBER NAME"))
{
sLine = ("\n") + sLine;
}
arrText.Add(sLine);
}
}
//separateJob(sLine);
}
//MessageBox.Show(sLine, "Select File", MessageBoxButtons.OK);
}
objReader.Close();
foreach (string sOutput in arrText)
{
output += sOutput; //puts on one line
}
//Output to file
System.IO.File.WriteAllText(@"D:\OutputTest.txt", output); //writes out in one line
MessageBox.Show(curFile, "Select File", MessageBoxButtons.OK);
}
I have never really asked a question here before so if im missing anything i'd be glad to post that as well. Mostly here I am lost on the logic. I want to be able to make a separate text file for every member.