You should be encrypting those files, but try this:
vb.net Code:
Public Function FindTextInDirectory(ByVal TextToFind As String, ByVal ParentFolder As String, ByVal SearchOption As IO.SearchOption) As String()
If Not IO.Directory.Exists(ParentFolder) Then Throw New IO.FileNotFoundException(ParentFolder + " does not exist.")
Try
Dim Files As New List(Of String)
For Each File As String In IO.Directory.GetFiles(ParentFolder, "*.dat", SearchOption)
Try
For Each Line As String In IO.File.ReadAllLines(File)
If Line.ToUpper().Contains(TextToFind.ToUpper()) Then
Files.Add(File)
End If
Next
Catch ex As Exception
Throw ex
End Try
Next
Return files.ToArray()
Catch ex As Exception
Throw ex
End Try
End Function
You can use it like this:
vb.net Code:
For Each file As String In Me.FindTextInDirectory("
[email protected]", "C:\Folder", IO.SearchOption.TopDirectoryOnly)
MessageBox.Show(file) ' path to file that contained text
Next