Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Application Settings Config File Path
Message
From
14/01/2011 08:36:30
 
 
To
14/01/2011 08:15:37
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01496034
Message ID:
01496154
Views:
31
Super Tim to the rescue! :)

Thanks, that looks like it works (at least on my development machine, will test later on client's)

>Frank,
>
>If you are going to reference it directly in a code file other than a page try this:
>
>HttpContext.Current.Server.MapPath()
>
>
>Tim
>
>>Yes, it's in a class based on mmAppConfiguration.
>>
>>There is no MapPath option showing in Intellisense when I type: System.Web.HttpServerUtility.
>>
>>The only options I have are Equals, ReferenceEquals, UrlTokenDecode, UrlTokenEncode
>>
>>>It is System.Web.HttpServerUtility. Ahh, you are using this somewhere other than in a web form? You may have to add System.Web but try typing HttpServerUtility.MapPath to see if it resolves.
>>>Tim
>>>
>>>>Whether or not I have the ~ there I still get a reference error with "Server". What should the Using statement be for that?
>>>>
>>>>If I just try this:
>>>>
>>>>
this.ReadKeysFromConfig("~/Admin/SIASSettings.config");<pre>
>>>>
>>>>then I get an error saying:
>>>>
>>>>Could not find a part of the path 'c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\~\Admin\SIASSettings.config'
>>>>
>>>>If I remove the ~ I assume I'll get a very similar message.
>>>>
>>>>
>>>>>I am using Server.MapPath successfully like this.
>>>>><pre>
>>>>>XmlDocument doc = new XmlDocument();
>>>>>doc.Load(Server.MapPath("/Xml/States.xml"));
>>>>>
>>>>>
>>>>>It is possible your path is not quite right. I think if you just take the tilde off you may have better luck. My file is in a directory "Xml" off of the root of the application path.
>>>>>Tim
>>>>>
>>>>>>Hi Tim,
>>>>>>
>>>>>>yes, this is the ASP.NET app. I have tried this too:
>>>>>>
>>>>>>
this.ReadKeysFromConfig("~/Admin/SIASSettings.config");
>>>>>>
>>>>>>and it didn't find the file (but then again, maybe I only tried it on my development machine).
>>>>>>
>>>>>>I believe I am using the sample code you gave me, so the path to this file is only ever referenced in one place.
>>>>>>
>>>>>>>Frank,
>>>>>>>
>>>>>>>Is this ASP.Net you are working on still? Do you need to use Server.MapPath for that? I was under the impression the path was still relevant to the application path. Try using the same syntax you are using for controls or other path references. I would also suggest putting a reference to this settings file somewhere in the app as a property so it only has to be accessed and read once.
>>>>>>>Tim
>>>>>>>
>>>>>>>>Hi,
>>>>>>>>
>>>>>>>>I have subclassed the mmAppConfiguration and have set it to use this config file:
>>>>>>>>
>>>>>>>>
this.ReadKeysFromConfig("C:\\Development\\Mere Mortals .NET Framework 2008\\SamaanSystems\\IAS.Web\\Admin\\SIASSettings.config");
>>>>>>>>
>>>>>>>>Of course this won't exist on the client's computer.
>>>>>>>>
>>>>>>>>I have tried using this:
>>>>>>>>
>>>>>>>>
//this.ReadKeysFromConfig(Server.MapPath(@"~/Admin/SIASSettings.config"));
>>>>>>>>
>>>>>>>>but that gives me an error on Server saying "The name 'Server' does not exist in the current context". If I try to resolve the reference the only option I have available is Microsoft.SqlServer.Server, which doesn't seem right to me.
>>>>>>>>
>>>>>>>>What should I use?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Reply
Map
View

Click here to load this message in the networking platform