Read the file sentence by sentence where sentence can be a multiple lines
if you want to make the differences in statement wise then I dont think it will be straight forward. You have to come up with some particular format. Like though statement has 1,2 or 3 lines it should and with "." dot. or you should keep starting and ending marker if there may be 2-3 statements in one line. The you can write the program to read file statement by statement by using this markers like below(I have wrote in one of my application). Note that markers used is $.
line = my.ReadLine();
if (line != string.Empty &&
line.StartsWith("$")) {
#region form the complete
question
completeQuestion =
line;
if(!completeQuestion.EndsWith("$"))
{
while(!(line =
questionsFile.ReadLine()).EndsWith("$"))
{
if(line.StartsWith("$"))
{
MessageBox.Show("The file " +
fileLocation + " contains a line which is not end
with);
continue;
}
if(line !=
string.Empty)
completeQuestion +=
"\n" + line;
}
if(line.StartsWith("$"))
{
MessageBox.Show("The file " +
fileLocation + " contains a followin question which is not end with
$.)
completeQuestion =
line;
} else
{
if (line !=
string.Empty)
completeQuestion +=
"\n" + line;
}
}
By Perry Popularity (894 Views)