CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2010
    Posts
    31

    How to find duplicates?

    I have some code which searches through directories and folders for mp3 files and then displays them to the list boxes.

    Code:
    foreach (string foldername in Directory.GetDirectories(DirectoryName))
                {
                    MP3Header mp3hdr = new MP3Header();
                    string Mp3Filename;
    
    
    
                    foreach (string filename in Directory.GetFiles(foldername))
                    {
                        string extension = Path.GetExtension(filename);
                        FileInfo f = new FileInfo(filename);
    
    
                        if (extension == FileTypeExtension)
                        {
                            this.listBox1.Items.Add(filename);
                        }
    
    
                        if (f.Length <= thisFileLength)
                        {
                            this.listBox2.Items.Add(filename);
    
                        }
    
                        // Form1 tag = new Form1();
    
                        bool boolIsMP3 = mp3hdr.ReadMP3Information(filename);
    
                        this.listBoxFileName.Items.Add(mp3hdr.strFileName);
                        this.listBox3.Items.Add(mp3hdr.lngFileSize.ToString());
                        this.listBoxBitRate.Items.Add(mp3hdr.intBitRate.ToString());
                        this.listBoxFrequency.Items.Add(mp3hdr.intFrequency.ToString());
                        this.listBoxstrMode.Items.Add(mp3hdr.strMode);
                        this.listBoxstrLength.Items.Add(mp3hdr.strLengthFormatted);
    
                        //Mp3Filename = filename;
    
                        Filelist.Add(mp3hdr.strFileName);
    
                        this.listBox4.Items.Add(Filelist);
    }

    How can I edit it so that it finds files which are the same as one another?

    For example if one file in one folder has the same name as another file in another folder?

    Code:
    foreach (FileName in Filelist)
                {
                    if (filename == mp3hdr.strFileName)
                    {
                        this.listBox4.Items.Add(filename);
                    }
                }
    Something along those lines?

  2. #2
    Join Date
    Apr 2007
    Location
    Florida
    Posts
    403

    Re: How to find duplicates?

    You've created this same thread 3 times on this forum. Stop.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured