So so far what my program does is goes through a file that you specify and takes the lines of text between 2 keywords and saves them to a seperate file for each block of text.
i.e
Start
stuff
stuffer
End
Start1
stuff
stuffer
End
The "stuff" in between will be saved to a diff text file for each block
But what i am trying to do now is instead of using keywords to mark the beginning and end i want to use brackets to mark it.
Start
[
[
stuffer
]
]
End
So the program instead of using Start and End to mark the beginning and end could use the bracket count....wouldnt it be something like:
so that when counter reaches 0 it will know that it has reached the end of a block of code...
this is what I have so far and the file that I have been using for testing
private void button1_Click(object sender, EventArgs e)
{
string path = "c:\\";
int counter = 0;
var masterList = new List<List<string>>();
using (var sr = new StreamReader(path + "test.txt"))
{
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
if (line.StartsWith("CLASS") || line.StartsWith("TYPE"))
{
if (line.Equals("{"))
{
counter = counter + 1;
}
if (line.Equals("}"))
{
counter = counter - 1;
}
var lineList = new List<string>();
while (!line.Equals("END"))
{
lineList.Add(line);
line = sr.ReadLine();
}
masterList.Add(lineList);
}
}
}
foreach (var lineList in masterList)
{
using (var sw = new StreamWriter(path + lineList[0] + "_test.txt"))
{
foreach (string line in lineList)
sw.WriteLine(line);
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.