当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET WebConfigurationManager.OpenMappedWebConfiguration方法代码示例

本文整理汇总了VB.NET中System.Web.Configuration.WebConfigurationManager.OpenMappedWebConfiguration方法的典型用法代码示例。如果您正苦于以下问题:VB.NET WebConfigurationManager.OpenMappedWebConfiguration方法的具体用法?VB.NET WebConfigurationManager.OpenMappedWebConfiguration怎么用?VB.NET WebConfigurationManager.OpenMappedWebConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Configuration.WebConfigurationManager的用法示例。


在下文中一共展示了WebConfigurationManager.OpenMappedWebConfiguration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: CreateFileMap

' Utility to map virtual directories to physical ones.
   ' In the current physical directory maps 
   ' a physical sub-directory with its virtual directory.
   ' A web.config file is created for the
    ' default and the virtual directory at the appropriate level.
    'You must create a physical directory called config at the
    'level where your app is running.
   Shared Function CreateFileMap() As WebConfigurationFileMap
      
      Dim fileMap As New WebConfigurationFileMap()
      
      ' Get he physical directory where this app runs.
      ' We'll use it to map the virtual directories
      ' defined next. 
      Dim physDir As String = Environment.CurrentDirectory
      
      ' Create a VirtualDirectoryMapping object to use
      ' as the root directory for the virtual directory
      ' named config. 
      ' Note: you must assure that you have a physical subdirectory
      ' named config in the curremt physical directory where this
      ' application runs.
        Dim vDirMap As New VirtualDirectoryMapping(physDir + _
        "\config", True)
      
      ' Add vDirMap to the VirtualDirectories collection 
      ' assigning to it the virtual directory name.
      fileMap.VirtualDirectories.Add("/config", vDirMap)
      
      ' Create a VirtualDirectoryMapping object to use
      ' as the default directory for all the virtual 
      ' directories.
        Dim vDirMapBase As New VirtualDirectoryMapping(physDir, _
        True, "web.config")
      
      ' Add it to the virtual directory mapping collection.
      fileMap.VirtualDirectories.Add("/", vDirMapBase)
      
    
#If DEBUG Then
      Dim key As String
      For Each key In  fileMap.VirtualDirectories.AllKeys
            Console.WriteLine("Virtual directory: {0} Physical path: {1}", _
            fileMap.VirtualDirectories(key).VirtualDirectory, _
            fileMap.VirtualDirectories(key).PhysicalDirectory)
      Next key
#End If

      ' Return the mapping.
      Return fileMap

    End Function 'CreateFileMap
开发者ID:VB.NET开发者,项目名称:System.Web.Configuration,代码行数:52,代码来源:WebConfigurationManager.OpenMappedWebConfiguration

示例2: OpenMappedWebConfiguration

' Show how to use the OpenMappedWebConfiguration(
' WebConfigurationFileMap, string)
Shared Sub OpenMappedWebConfiguration1()
   
   ' Create the configuration directories mapping.
   Dim fileMap As WebConfigurationFileMap = CreateFileMap()
   
   Try
      
      ' Get the Configuration object for the mapped
      ' virtual directory.
         Dim config As System.Configuration.Configuration = _
         WebConfigurationManager.OpenMappedWebConfiguration( _
         fileMap, "/config")
      
      ' Define a nique key for the creation of 
      ' an appSettings element entry.
      Dim appStgCnt As Integer = config.AppSettings.Settings.Count
      Dim asName As String = "AppSetting" + appStgCnt.ToString()
      
      ' Add a new element to the appSettings.
         config.AppSettings.Settings.Add(asName, _
         DateTime.Now.ToLongDateString() + " " + _
         DateTime.Now.ToLongTimeString())
      
      ' Save to the configuration file.
      config.Save(ConfigurationSaveMode.Modified)
      
      ' Display new appSettings.
         Console.WriteLine("Count:  [{0}]", _
         config.AppSettings.Settings.Count)
      Dim key As String
      For Each key In  config.AppSettings.Settings.AllKeys
             Console.WriteLine("[{0}] = [{1}]", _
             key, config.AppSettings.Settings(key).Value)
      Next key
   
   Catch err As InvalidOperationException
      Console.WriteLine(err.ToString())
   End Try
   
   Console.WriteLine()
End Sub
开发者ID:VB.NET开发者,项目名称:System.Web.Configuration,代码行数:43,代码来源:WebConfigurationManager.OpenMappedWebConfiguration

示例3: OpenMappedWebConfiguration

' Show how to use the OpenMappedWebConfiguration(
' WebConfigurationFileMap, string, string).
Shared Sub OpenMappedWebConfiguration2()
   
   ' Create the configuration directories mapping.
   Dim fileMap As WebConfigurationFileMap = CreateFileMap()
   
   Try
      
      ' Get the Configuration object for the mapped
      ' virtual directory.
         Dim config As System.Configuration.Configuration = _
         WebConfigurationManager.OpenMappedWebConfiguration( _
         fileMap, "/config", "config")
      
      ' Define a nique key for the creation of 
      ' an appSettings element entry.
      Dim appStgCnt As Integer = config.AppSettings.Settings.Count
      Dim asName As String = "AppSetting" + appStgCnt.ToString()
      
      ' Add a new element to the appSettings.
         config.AppSettings.Settings.Add(asName, _
         DateTime.Now.ToLongDateString() + " " + _
         DateTime.Now.ToLongTimeString())
      
      ' Save to the configuration file.
      config.Save(ConfigurationSaveMode.Modified)
      
      ' Display new appSettings.
         Console.WriteLine("Count:  [{0}]", _
         config.AppSettings.Settings.Count)
      Dim key As String
      For Each key In  config.AppSettings.Settings.AllKeys
             Console.WriteLine("[{0}] = [{1}]", _
             key, config.AppSettings.Settings(key).Value)
      Next key
   
   Catch err As InvalidOperationException
      Console.WriteLine(err.ToString())
   End Try
   
   Console.WriteLine()
End Sub
开发者ID:VB.NET开发者,项目名称:System.Web.Configuration,代码行数:43,代码来源:WebConfigurationManager.OpenMappedWebConfiguration

示例4: OpenMappedWebConfiguration

' Show how to use the OpenMappedWebConfiguration(
' WebConfigurationFileMap, string, string, string).
Shared Sub OpenMappedWebConfiguration3()
   
   ' Create the configuration directories mapping.
   Dim fileMap As WebConfigurationFileMap = CreateFileMap()
   
   Try
      
      ' Get the Configuration object for the mapped
      ' virtual directory.
         Dim config As System.Configuration.Configuration = _
         WebConfigurationManager.OpenMappedWebConfiguration( _
         fileMap, "/config", "config", "config")
      
      ' Define a nique key for the creation of 
      ' an appSettings element entry.
      Dim appStgCnt As Integer = config.AppSettings.Settings.Count
      Dim asName As String = "AppSetting" + appStgCnt.ToString()
      
      ' Add a new element to the appSettings.
         config.AppSettings.Settings.Add(asName, _
         DateTime.Now.ToLongDateString() + " " + _
         DateTime.Now.ToLongTimeString())
      
      ' Save to the configuration file.
      config.Save(ConfigurationSaveMode.Modified)
      
      ' Display new appSettings.
         Console.WriteLine("Count:  [{0}]", _
         config.AppSettings.Settings.Count)
      Dim key As String
      For Each key In  config.AppSettings.Settings.AllKeys
             Console.WriteLine("[{0}] = [{1}]", _
             key, config.AppSettings.Settings(key).Value)
      Next key
   
   Catch err As InvalidOperationException
      Console.WriteLine(err.ToString())
   End Try
   
   Console.WriteLine()
End Sub
开发者ID:VB.NET开发者,项目名称:System.Web.Configuration,代码行数:43,代码来源:WebConfigurationManager.OpenMappedWebConfiguration


注:本文中的System.Web.Configuration.WebConfigurationManager.OpenMappedWebConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。