首页 > 解决方案 > 如何检查文件列表的文件内容是否相同?

问题描述

我有一个文件列表并希望检查这些文件是否相同(内容/大小)

IEnumerable<string> results = GetFiles("DirectorPath");    //This function returns the list of file names 
            foreach (string entry in results)
            {
                FileInfo fileInfo = new FileInfo(Path.Combine("C:\beta\source"), entry));
                //How I do check if the elements of **results** are identical or not ??
                //Problem is that the **results** may have (2,3,4) number of files, not same every time
            }

我尝试的是

foreach (string entry in results)
            {
                FileInfo fileInfo = new FileInfo(Path.Combine("C:\beta\source"), entry));
                recentlyModFiles.Add(fileInfo); //Add the elements into another container and check for the content but will have to again use a forloop
            }
            

有人可以用更好的方法帮助我吗?

让我知道是否需要任何其他数据

谢谢。

编辑:我的问题陈述有多个(2,3,4..)文件数量,每次都不相同,而不仅仅是2个文件

标签: c#

解决方案


推荐阅读