示例#1
0
        public void RemoveDuplicate(string directory)
        {
            FileSystemInfo[] infos    = new DirectoryInfo(directory).GetFileSystemInfos();
            List <string>    arrFiles = new List <string>();

            arrFiles = CountFiles(infos);

            string str = "";

            for (var i = 0; i < arrFiles.Count; i++)
            {
                var name = arrFiles[i];
                var file = new FileInfo(name);
                str = file.Name.Replace(file.Extension, "");

                for (var g = i + 1; g < arrFiles.Count; g++)
                {
                    var name2 = arrFiles[g];

                    var file2 = new FileInfo(name2);
                    if (file2.Name.Contains(str) && file2.Name.Length <= file.Name.Length + 7)
                    {
                        var check = false;
                        using (var img1 = Image.FromFile(file.FullName))
                            using (var img2 = Image.FromFile(file2.FullName))
                            {
                                var byteArr1 = ImageToByteArray(img1);
                                var byteArr2 = ImageToByteArray(img2);

                                if (CleanUp.ByteArrayCompare(byteArr1, byteArr2)) //byteArr1.SequenceEqual(byteArr2))
                                {
                                    check = true;
                                }
                            }

                        if (check)
                        {
                            file2.Delete();
                            arrFiles.RemoveAt(g);
                            g--;
                        }
                    }
                }
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var stuff = new CleanUp();

            if (removeSmall)
            {
                stuff.RemoveSmall(strDirectory);
            }

            if (removeDuplicate)
            {
                stuff.RemoveDuplicate(strDirectory);
            }

            if (moveFiles)
            {
                stuff.SortImages();
            }

            this.DialogResult = DialogResult.OK;
        }