Question : Late bound calls to file system methods in the Visual Basic runtime are not permitted.


Can someone please explain why this simple routine fails? ...

..............

Dim tem As String = ""
        tempno = FreeFile()
       
        FileOpen(tempno, "c:\myvbastext\listoffilesandpaths.txt", OpenMode.Input)
        i% = 0
        While Not EOF(tempno)
            i% = i% + 1
            Input(tempno, tem)

                   End While

............

The error message is "Late bound calls to file system methods in the Visual Basic runtime are not permitted." and the error is described as a "SecurityException was unhandled."

Thank you.

Answer : Late bound calls to file system methods in the Visual Basic runtime are not permitted.

Try this and see if it works instead of the FileOpen
1:
2:
3:
4:
5:
6:
7:
8:
9:
Dim i As Integer
        Dim currentRow As String

        Using myreader As New FileIO.TextFieldParser("c:\temp\adam.txt")
            While Not myreader.EndOfData
                currentRow = myreader.ReadLine()
                i = i + 1
            End While
        End Using
Random Solutions  
 
programming4us programming4us