Ejemplo n.º 1
0
        public async void CompareAsync()
        {
            Console.WriteLine("Введите первую папку:");
            string path1 = Console.ReadLine();

            Console.WriteLine("Введите вторую папку:");
            string path2 = Console.ReadLine();

            if (Directory.Exists(path1) && Directory.Exists(path2))
            {
                IEnumerable <FileInfo> list1 = await GetInitialListAsync(path1);

                IEnumerable <FileInfo> list2 = await GetInitialListAsync(path2);

                FileCompare myFileCompare = new FileCompare();

                var queryList1Only = await GetResultListAsync(list1, list2, myFileCompare);

                var queryList2Only = await GetResultListAsync(list2, list1, myFileCompare);

                WriteInfo(queryList1Only, "Только в " + path1 + ":");
                WriteInfo(queryList2Only, "Только в " + path2 + ":");
            }
        }
Ejemplo n.º 2
0
 private IEnumerable <string> GetResultList(IEnumerable <FileInfo> list1, IEnumerable <FileInfo> list2, FileCompare myFileCompare)
 {
     return(list1.Except(list2, myFileCompare).Select(x => x.FullName));
 }
Ejemplo n.º 3
0
 private async Task <IEnumerable <string> > GetResultListAsync(IEnumerable <FileInfo> list1, IEnumerable <FileInfo> list2, FileCompare myFileCompare)
 {
     return(await Task.Run(() => GetResultList(list1, list2, myFileCompare)));
 }