Hi,

I am trying to read from a number of files and trying to save the contents of each file in an array of strings. The error that I keep receiving is: Object reference not set to an instance of an object.

Public Sub Read(ByVal template As String(), ByVal newfiles As String())
Try
Dim strfilename As String
Dim temp_only_for_appending As String()
Dim count As Integer = 0

'Looping through each file in the the string array passed

For Each file As String In template

'Read all text from each template file
strfilename = System.IO.File.ReadAllText(file)
'Concetanate the strings and copy it to an array item

'********THIS IS WHERE IT FAILS******
temp_only_for_appending(count) = (strinputstring & vbCrLf & vbCrLf & strfilename)
count += 1 'Increment the array counter
Next

Catch E As Exception
' Let the user know what went wrong.
MsgBox("The file could not be read: ")
MsgBox(E.Message)
End Try

End Sub

Please tell me what I am doing incorrectly so that I can fix my code. I need some help urgently. Thanks in advance.