检查TXT文档与anther TXT Doc

时间:2013-07-18 17:06:00

标签: c#

我会尽我所能在这里找到txt文件的片段,供你查看。他们中的大多数都是上课,这对我来说需要一些工作。我们的想法是获取一个txt文件,其中包含超过500个位置的列表,并在50个位置的列表中运行它们并拉出匹配的列表。正如我所说,我已经尝试了很多不同的方法,以及我所知道的所有方法,而且我似乎无法让它正常工作。我正在尝试采用以下代码并让它执行上述操作。这有帮助。

InPutBox = Input.Text;
    int x = 1;
    var lines = Input.Text.Split(new string[] { Environment.NewLine },StringSplitOptions.None);

    for (var index = 0; index < lines.Length; index++)
    {

        var line = lines[index];

        do
        {
            x++;
            System.Console.WriteLine("'{0}'", InPutBox);
            bool test1 = InPutBox.StartsWith("TAG");
            bool test2 = InPutBox.EndsWith("TAG");
            if (test1 && test2)
            {
                int first = InPutBox.IndexOf("TAG");
                int last = InPutBox.LastIndexOf("TAG");
                InPutBox = InPutBox.Substring(first, last - first);
            }
        }
        while (x < 50);
        System.Console.WriteLine("'{0}'", line);
        if ((line.StartsWith("TAG") && line.EndsWith("TAG")))
        {
            MessageBox.Show("These are errors in line" + index + ": " + line);
            break;
        }

    }

0 个答案:

没有答案
相关问题