Identifying duplicate files?

littlebigman

Well-known member
Joined
Jan 5, 2010
Messages
75
Programming Experience
Beginner
Hello

I need to write an application that does the following, and I figured it was a good opportunity to write my first VB.Net application:

1. Get the list of fixed disks in the computer
2. For each disk, recurse through all its directories and sub-directories looking for filenames that match a given regex (eg. MyFile.\d{3})
3. If found, hash this file to get a unique ID, eg. MD5 (just to check if this file already exists elsewhere)
4. If this file hasn't already been seen elsewhere on the disk, copy it to a central directory

If you know of any piece of code that can get me started, I'm interested :)

Thank you.
 
System.IO Namespace ()
VB.NET:
For Each drive As IO.DriveInfo In IO.DriveInfo.GetDrives
    If drive.DriveType = IO.DriveType.Fixed Then
       
    End If
Next
Also check out the classes in System.IO namespace for working with files and folders.

MD5CryptoServiceProvider Class (System.Security.Cryptography)
VB.NET:
Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
Using fs As IO.FileStream = IO.File.OpenRead(filepath)
    Dim hash As String = Convert.ToBase64String(md5.ComputeHash(fs))

End Using
md5.Clear()
 
Back
Top