vb.net.net-4.7.2

What is the difference between the two versions of OpenTextFileReader() in Visual Basic?


Visual Basic .Net has two versions of OpenTextFileReader(), as listed below:

Microsoft.VisualBasic.FileIO.FileSystem.OpenTextFileReader(String) As System.IO.StreamReader
Microsoft.VisualBasic.MyServices.FileSystemProxy.OpenTextFileReader(String) As System.IO.StreamReader

Are there any differences between the two? If so, what are they?

Also please discuss any pros & cons that may be relevant. For instance, calling from FileSystem vs FileSystemProxy.

I see one is Shared but the other is not. I understand this means one applies to the base class, and the other to instances, but I'm not sure if/how that might affect the differences between them.


Solution

  • Based on the reference source here, Microsoft.VisualBasic.MyServices.FileSystemProxy.OpenTextFileReader(String) is nothing more than a trampoline:

    Public Function OpenTextFileReader(ByVal file As String) As IO.StreamReader
        Return Microsoft.VisualBasic.FileIO.FileSystem.OpenTextFileReader(file)
    End Function
    

    I suspect it's there to facilitate the ergonomic My namespace.