无法获取app.config文件路径

时间:2015-04-08 09:02:04

标签: vb.net app-config configuration-files

我想获取app.config文件的路径,但无法获取它。这是我一直在尝试的方法:

Public Shared Function GetConfiguration(Optional ByVal fileName As String = "")
Dim map As System.Configuration.ExeConfigurationFileMap = New ExeConfigurationFileMap()
    'read file from given path
    Dim objApplicationIdentity As New ApplicationIdentity("")

    If Not String.IsNullOrEmpty(fileName) Then
        map.ExeConfigFilename = "~" & fileName ' the root web.config  
    Else
        map.ExeConfigFilename = "..\\app.config" ' the root web.config  
    End If
    ''read cogfiguration settings
    strConfig = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None)


End Function

我如何获得路径?

0 个答案:

没有答案