當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。