[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Webconfig + webservice + vb.net

Posted on 2007-11-14
2
Medium Priority
?
457 Views
Last Modified: 2008-02-01
I have a basic question. I am in the process of cleaning up some code. I have a directory path stored in my webconfig file of a web service.
<add key="FilePath" value="c:\\projects\data\spider\" />

Dim FilePath as string
 FilePath=   System.Configuration.ConfigurationManager.AppSettings("FilePath")
It works fine .

In my web service I have a few methods which use this file path. In stead of calling this
Dim FilePath as string
 FilePath=   System.Configuration.ConfigurationManager.AppSettings("FilePath")
 in each and every method can I not set this up as when I start my service instead of always reading it from the webconfig file.
Where would I place this code of line such that all methods can access it? Is it even doable in a webservice.
Just curious!!
0
Comment
Question by:YRKS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 21

Accepted Solution

by:
surajguptha earned 750 total points
ID: 20285615
The reason we have the AppSettings is because we dont have to put the app setting value in 10 different places. Instead we put it in the config file and call it with some name. That by itself is a simplification.

If you want it to be made even simpler.
You can write a class that would read the configuration file. In the get property you can add this code

But again if it was me i would just leave it as Configmanager :)
0
 
LVL 15

Assisted Solution

by:Solar_Flare
Solar_Flare earned 750 total points
ID: 20285636
YRKS,

the web.config file is loaded into memory when the application starts, so in fact it will not be hitting the disk every time you ask for the filepath.

if you really wanted to, you could put it in a static/shared object and use that object everywhere in your code but since it's not hitting the disk that probably isn't necessary.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Six Sigma Control Plans
Progress

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question