473,513 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

add location elemet to web.config programmatically

How to add next to web.config

<location path="9998886">
<system.web>
<compilation
tempDirectory="D:\logs\temporary_asp_net_files\999 8886" />
</system.web>
</location>

<location path="444">
<system.web>
<compilation tempDirectory="D:\logs\temporary_asp_net_files\444 "
/>
</system.web>
</location>

I can read and modify existing locations but don't know how to add/delete
new locations.

Can someone point me to right direction or give some example.

' Open configuration.
Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Nothi ng)
Dim value As ConfigurationLocationCollection = config.Locations

Dim myLocation As ConfigurationLocation
For Each myLocation In value
If myLocation.Path = "9998886" Then

Console.WriteLine(myLocation.Path)

Dim myLocationConfiguration As Configuration =
myLocation.OpenConfiguration()
' Get the section related object.

Dim configSection As System.Web.Configuration.CompilationSection =
_CType(myLocationConfiguration.GetSection("system. web/compilation"), _
System.Web.Configuration.CompilationSection)

Console.WriteLine("Location Configuration File Path: {0}",
myLocationConfiguration.FilePath)
' Display TempDirectory property.

Console.WriteLine("TempDirectory: {0}", _
configSection.TempDirectory)

'' Set TempDirectory property.
'configSection.TempDirectory =
"D:\logs\temporary_asp_net_files\novi_temp_fol der"

'' Update if not locked.
'If Not configSection.SectionInformation.IsLocked Then
' myLocationConfiguration.Save()
' Console.WriteLine("** Configuration updated.")
'Else
' Console.WriteLine("** Could not update, section is locked.")
'End If
'' Display TempDirectory property.
'Console.WriteLine("TempDirectory: {0}", _
' configSection.TempDirectory)

End If

Next

Console.WriteLine(value.Count)
Oct 25 '08 #1
0 2402

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3100
by: Rim | last post by:
Hi, How can I control the location of the bytecode files? The reason I ask is I want to place the bytecode in a directory different than source code for backup reasons. Our backup system is...
2
4336
by: Vincenzo Davi | last post by:
I have created a dll with several classes in C#. One of the classes references image files in the subdirectories of the bin/Release folder (basically where the dll resides). Now, I want to use...
1
2732
by: JD | last post by:
I've got a Windows Forms application that I'd like to NOT have an app.config file for. There are, however, a few "utility" assemblies used by the application and I'd like them to be in a...
14
37129
by: Frances Del Rio | last post by:
I'm trying to open a url in a new window while pg loads (but NOT in a pop-up..) I need to do sthg like // while pg is loading.. window.location ='page.html' // but I need this to open in a...
2
2594
by: TK | last post by:
What's the best way to edit web.config programmatically? I want to have an aspx page as a GUI for web admins to modify the roll-base security portion of the web.config(s) on a server. please...
1
1398
by: Fredrik Celin | last post by:
Hello. Is there anybody who knows how I can change som information in the machine.config in a deployment project for a web application? Do I have to change replace the file with a new (and how...
1
2033
by: mike | last post by:
I have 2 sites in my company. My .NET site uses a master page and a Menu control connected to a sitemap. In my sitemap file I would like to be able to do something like this: <sitemap>...
6
15286
by: Andrew Jocelyn | last post by:
Hi How do I programmatically change (read/write) the values in this app.config file at runtime? Specifically I want to change the client endpoint address but it would be nice to change other...
4
1652
by: David Williams | last post by:
I am familiar with creating custom configuration settings and accessing them. However, for a current requirement, I need to control the various settings in my custom configuration section by...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.