Hello. I am creating a program at work that will do many database operations. One of which is searching through the text of some text files. I have some code that will iterate through all the files, open them up, and then search for the string that was entered.

The problem I have ran into is, the directory in which all the text files are stored is password protected and I am not sure how to open the directory by passing a password to it.

The directory is on the network (not my machine).

Here is the code I use to Do the required operation, if it will be of any help. Thank you in advance


Code:
Dim what As String = InputBox("What String would you like to search for?", "Please enter a Search Text", "text")
        Dim x, y, z, i As Integer
        Dim fname, txt As String
        Dim FileArray() As String
        y = Directory.GetFiles("[Directory Name]").Length
        ReDim FileArray(y)
        i = 0
        z = 0

        For Each fname In Directory.GetFiles("[Directory Name]")
            FileArray(z) = fname
            z += 1
        Next

        ReDim TextArray(y, 2)
        For x = 0 To y - 1
            Dim od As OpenFileDialog = New OpenFileDialog()
            Dim FlName As String = FileArray(x)
            od.FileName = FlName
            Dim FS As FileStream
            FS = od.OpenFile
            Dim SR As New StreamReader(FS)
            txt = SR.ReadToEnd
            If InStr(LCase(txt), what) >= 1 Then
                TextArray(i, 1) = txt
                ListBox1.Items.Add(od.FileName)
                i += 1
            End If
            SR.Close()
            FS.Close()
        Next