diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..93621e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.vs +bin/ +obj/ +packages/ +*.csproj.user diff --git a/App.config b/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DuplicateFinder.csproj b/DuplicateFinder.csproj new file mode 100644 index 0000000..f123027 --- /dev/null +++ b/DuplicateFinder.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {9A29BAE2-2C0A-4185-94E7-AA4591EEE377} + Exe + DuplicateFinder + DuplicateFinder + v4.8 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DuplicateFinder.sln b/DuplicateFinder.sln new file mode 100644 index 0000000..70e3c2a --- /dev/null +++ b/DuplicateFinder.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35931.197 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DuplicateFinder", "DuplicateFinder.csproj", "{9A29BAE2-2C0A-4185-94E7-AA4591EEE377}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9A29BAE2-2C0A-4185-94E7-AA4591EEE377}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A29BAE2-2C0A-4185-94E7-AA4591EEE377}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A29BAE2-2C0A-4185-94E7-AA4591EEE377}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A29BAE2-2C0A-4185-94E7-AA4591EEE377}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0FB7C224-6C72-4AA9-8264-CAE25D6B0A33} + EndGlobalSection +EndGlobal diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..35c42dc --- /dev/null +++ b/Program.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Security.Cryptography; + +namespace DuplicateFinder +{ + internal class Program + { + private static string CalculateSha1(string filePath) + { + using (var sha1 = SHA1.Create()) + { + using (var stream = File.OpenRead(filePath)) + { + byte[] hashBytes = sha1.ComputeHash(stream); + return BitConverter.ToString(hashBytes).Replace("-", "").ToLower(); + } + } + } + + static void Main(string[] args) + { + Console.Write("Enter directory path: "); + string directoryPath = Console.ReadLine(); + + Dictionary> fileHashes = new Dictionary>(); + + foreach (string filePath in Directory.EnumerateFiles(directoryPath, "*.*", SearchOption.AllDirectories)) + { + string hash = CalculateSha1(filePath); + + if (fileHashes.ContainsKey(hash)) + { + fileHashes[hash].Add(filePath); + } + else + { + fileHashes[hash] = new List { filePath }; + } + } + + Console.WriteLine("\nDuplicate files:"); + foreach (var group in fileHashes.Values.Where(v => v.Count > 1)) + { + foreach (var filePath in group) + { + Console.WriteLine(filePath); + } + Console.WriteLine(); + } + + Console.ReadKey(); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4b134f8 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные с этой сборкой. +[assembly: AssemblyTitle("DuplicateFinder")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DuplicateFinder")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// из модели COM задайте для атрибута ComVisible этого типа значение true. +[assembly: ComVisible(false)] + +// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM +[assembly: Guid("9a29bae2-2c0a-4185-94e7-aa4591eee377")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Номер редакции +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]