I am trying to save the text file in this path:\"C:\\Test\\test.txt\" and when the file is already opened I need to check whether the file is opened and I need to close it b
I do not believe there is a property that will allow for you to check if the streamreader is open or not.
Best practice seems to be to .close the reader when done with it. (All in the method that it was used in.)
You could try a try block to handle the exception if you are still getting one.
May be able to find additional info and some sample code here. Good Luck.
MSDN! StreamReader
EDIT: You may be able to check using this. IO.File
Private Function CheckFile(ByVal filename As String) As Boolean
Try
System.IO.File.Open(filename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.None)
FileClose(1)
Return False
Catch ex As Exception
Return True
End Try
End Function