Search code examples
vb.netfileinfo

FileInfo: passing FileInfo argument to method


I have the following VB function which takes a FileInfo object as a parameter:

Public Shared Shadows Sub Start(ByVal filePath As FieldInfo)
XmlConfigurator.ConfigureAndWatch(New System.IO.FileInfo(filePath.ToString()))

End Sub

In another class I have the following code calling that 'Start' method. But VisStudio indicates there is a problem with the 'FilePath' argument that I'm passing. Thanks in advance!

'Initialize FileInfo object to pass to Start method
        Dim path As String =             Dim filePath As FileInfo = New FileInfo(path)

        LoggingManager.Start(**FilePath**)

Solution

  • It looks like you mis-declared the Start function, it should be FileInfo not FieldInfo

    Public Shared Shadows Sub Start(ByVal filePath As FileInfo)
        XmlConfigurator.ConfigureAndWatch(filePath)
    End Sub