Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 706239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:08:38+00:00 2026-05-14T04:08:38+00:00

I don’t know enough about VB.Net (2008, Express Edition) yet, so I wanted to

  • 0

I don’t know enough about VB.Net (2008, Express Edition) yet, so I wanted to ask if there were a better way to find files with different names but the same contents, ie. duplicates.

In the following code, I use GetFiles() to retrieve all the files in a given directory, and for each file, use MD5 to hash its contents, check if this value already lives in a dictionary: If yes, it’s a duplicate and I’ll delete it; If not, I add this filename/hashvalue into the dictionary for later:

'Get all files from directory
Dim currfile As String
For Each currfile In Directory.GetFiles("C:\MyFiles\", "File.*")
    'Check if hashing already found as value, ie. duplicate
    If StoreItem.ContainsValue(ReadFileMD5(currfile)) Then
        'Delete duplicate
    'This hashing not yet found in dictionary -> add it
    Else
        StoreItem.Add(currfile, ReadFileMD5(currfile))
    End If
Next

Is this a good way to solve the issue of finding duplicates, or is there a better way I should know about?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:08:38+00:00Added an answer on May 14, 2026 at 4:08 am

    You can optimise this by the following

    • Iterate all the files and record the filename and length
    • Then compare (MD5) each file only with those that are the same length
    • This is one of those tasks that is called embarrassingly parallel, so you should be able to use mulitple threads to do this and more efficiently, and since each comparison is independent
    • You only need to compare one file to another once not both ways round, ie. if you do compare(f1, f2) then you don’t need to do compare(f2, f1)

    I’ve sure there are many others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know if there is a better way to do this, so that is
Don't know how to google for such, but is there a way to query
Don't ask why, but is there any way to suppress a failed linking error?
don't know if the title describes anything about what I'm trying to say but
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know how to explain it better but i'm trying to get a response
Don't know a whole lot about streams. Why does the first version work using
Don't know if this is the right place to ask this, but I will
Don't know where else to ask, but from one day to the other my
Don't know if it's I'm doing it wrong or if there's a bug (I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.