0

I have a directory with .txt files in it. I am writing each file's line to an array and need to know if any lines in a file match any lines in another file.

Example:

If any item in Array1 = any item in Array2 then...

Code thus far:

For Each foundBaseFile As String In My.Computer.FileSystem.GetFiles _
 (DataDir, _
     FileIO.SearchOption.SearchTopLevelOnly, "*.vpk.txt")
        Dim BaseTextArray = IO.File.ReadAllLines(foundBaseFile)
        For Each foundCheckFile As String In My.Computer.FileSystem.GetFiles _
 (DataDir, _
     FileIO.SearchOption.SearchTopLevelOnly, "*.vpk.txt")
            If Not foundBaseFile = foundCheckFile Then
                Dim CheckTextArray = IO.File.ReadAllLines(foundCheckFile)
                'If any item in CheckTextArray = any item in BaseTextArray then
                '    Do X
                'End If
            End If
        Next
    Next

Thanks!

2 Answers 2

1

This should do the trick.

If BaseTextArray.Any(Function(o) CheckTextArray.Contains(o)) Then
  ' Do X
Sign up to request clarification or add additional context in comments.

Comments

0

Declare two array variable

dim arr1() as string
dim arr2() as string

Read values from .txt file line b line and add to each arrarlevel. You can also split lines by vbnewline

then use

Array.Indexof() 

method to find whether values in first array string exist in other.

If indx >1 then
True
Else
False
end if

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.