Git Программа в стиле Diff C# - PullRequest
0 голосов
/ 16 апреля 2020

Я создаю программу, аналогичную целям Git Diff, но не в состоянии выполнить некоторые вещи, такие как печать, какие строки в файлах отличаются, и выделение слов, которые отличаются / отсутствуют. Я попробовал что-то вроде этого, есть ли конкретная вещь в библиотеке, которую я мог бы использовать? (Этот фрагмент кода только из класса МЕНЮ)

 {
        menu menu = new menu();
        DirectoryRead dr = new DirectoryRead();

        //create array allFiles from bin/debug directory contents
        List<string> allFiles = dr.GetFiles();

        //choose two files to check if different. These are the file names.
        string file1 = menu.TextChoose(allFiles, "First File");
        string file2 = menu.TextChoose(allFiles, "Second File");


        //reads the file contents into an object 'readfile'(see Arrayreader constructor and 'readfile' property)
        ArrayReader firstArray = new ArrayReader(file1);
        ArrayReader secondArray = new ArrayReader(file2);


        bool isEqual = Enumerable.SequenceEqual(firstArray.readArray, secondArray.readArray);
        if (isEqual == true)
        {
            Console.WriteLine($"{file1} and {file2} are the the same!");
        }
        if (isEqual == false)
        {
            Console.WriteLine($"{file1} and {file2} are different!");
            string[] file1F = File.ReadAllLines(Path.Combine(dr, file1));
            string[] file2F = File.ReadAllLines(Path.Combine(dr ,file2));

            for (int i = 1; i < file2F.Length; i++)
            {
                if (file2F[i] != file2F[i])
                {
                    Console.WriteLine("Line: {0}, Old: {1}, New: {2}", i, file1F[i], file2F[i]);
                }
            }
        }

        menu.endProgram();
    }
}

}

Любая помощь приветствуется

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...