简体   繁体   中英

How to go to next line in file

while (readIt.Peek() >= 0) {
    if (line.Contains("LogObjectUsage@1000000000 : Record 50000;")) {
        MessageBox.Show("Fajl ne treba da se menja");
        System.IO.File.Copy(txtb_Input_Folder.Text + Path.GetFileName(fileName), txtb_Output_folder.Text + Path.GetFileName(fileName), true);

    } else {
        line = readIt.ReadLine();
        if (line.Contains("PROPERTIES") && !line.Contains("OBJECT-PROPERTIES")) {
            sb.Append(line);
            nasao_prop = true;
        }.........

So the problem is when it finds"LogObjectUsage@1000000000 : Record 50000;" then I am in while loop, and I don't know how to go to the next line.

I am stuck in that line and I get infinitely TextBoxes. Can someone help me? How can I read in the next line after I found "LogObjectUsage@1000000000 : Record 50000;" line?

It feels like you want to first read a line, then inspect it. What you're doing is trying to read the line too late into the workflow.

while (readIt.Peek() >= 0)
{
    var line = readIt.ReadLine();
    if (line.Contains("LogObjectUsage@1000000000 : Record 50000;"))
    {
        MessageBox.Show("Fajl ne treba da se menja");
        System.IO.File.Copy(txtb_Input_Folder.Text + Path.GetFileName(fileName), txtb_Output_folder.Text + Path.GetFileName(fileName), true);

    }
    else
    {
        if (line.Contains("PROPERTIES") && !line.Contains("OBJECT-PROPERTIES")) {
            sb.Append(line);
            nasao_prop = true;
        }
        .........
    }
    ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM