Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'MR_List listbox should contain the filenames, Path is the path to the files
- 'Doesn't work for files under 0.09 kb can be changed (99 is the minimum bytes it will check for match)
- Dim Container As String = "$"
- Dim Path As String = Current_Path_MR
- Dim Duplicates As Integer = 0
- Dim Duplicates_Container = Nothing
- For i As Integer = 0 To CInt(MR_List.Items.Count) - 1
- Dim CurrentFile As String = String.Format("{0}\{1}", Path, MR_List.Items(i).ToString)
- Dim CurrentInfo As System.IO.FileInfo
- CurrentInfo = My.Computer.FileSystem.GetFileInfo(CurrentFile)
- Dim FileSize As Long = CurrentInfo.Length
- If Container.Contains(CStr(FileSize)) = True Then
- Dim Container_Match As String = Regex.Split(Container, String.Format(":{0}", CStr(FileSize))).GetValue(0)
- Dim SplitContainer() As String = Regex.Split(Container_Match, ">")
- Dim SplitMatch As String = (CStr(SplitContainer.GetValue(SplitContainer.Length - 2)).Split("*").GetValue(0))
- If GetBase64(CurrentFile, 99) = GetBase64(SplitMatch, 99) = True Then
- Duplicates += 1
- Duplicates_Container &= String.Format("{0}*", SplitMatch)
- End If
- End If
- Container &= String.Format("{0}*{1}>", CurrentFile, FileSize)
- Next
- Try
- MessageBox.Show(String.Format("Found {0} Duplicates", Duplicates))
- Dim Results() As String = Duplicates_Container.split("*")
- Dim Message As String = Nothing
- For Each x As String In Results
- Message &= x & Environment.NewLine
- Next
- MessageBox.Show(Message)
- Catch ex As Exception
- End Try
- Private Function GetBase64(ByVal Filename As String, ByVal Chars As Integer)
- Dim Temp As String = Nothing
- Using BinaryFile As FileStream = New FileStream(Filename, FileMode.Open)
- Dim BinRead As BinaryReader = New BinaryReader(BinaryFile)
- Dim BinBytes As Byte() = BinRead.ReadBytes(CInt(BinaryFile.Length))
- Temp = Convert.ToBase64String(BinBytes).Substring(0, Chars)
- BinaryFile.Close()
- End Using
- Return Temp.Substring(0, Chars)
- End Function
Advertisement
Add Comment
Please, Sign In to add comment