Solved

UPLOAD file path in webconfig

Posted on 2011-03-11
4
698 Views
Last Modified: 2012-05-11
I am building a project for a client.  I need to be able to upload files to a directory ... I was thinking about putting the path into the webconfig so that the client could just change the name latter to what works for them when the get the code...

Could somebody tell me how that would be done OR if there would be a better way to do that?
0
Comment
Question by:vbnetcoder
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
mayankagarwal earned 500 total points
Comment Utility
For global variable you can use the <app key="varName" value="varValue"> tag in web.config file in your asp.net project. There are some other ways also to declare a global variable. You can also use application or session objects to maintain your data between multiple pages. This is the treditional way to make a variable global, but in asp.net we can also use the web.config setting for global declaration. The important part of using the global var in web.config file is that you can change the values on the fly. Means you dont need to complie your application.

for app setting the syntax is

<appSettings>
<add key="varName" value="varValue" />
<appSettings>

to access the variable

string strVar = System.Configuration.ConfigurationSettings.AppSettings["varName"].

For application variables

'To store a variable:
Application.Lock()
Application("MyVar")="whatever"
Application.Unlock()

'to retrieve the variable:
Dim s as String = Application("MyVar").ToString()
0
 

Author Comment

by:vbnetcoder
Comment Utility
Is their any way to put path into session automatically when the application starts so that I can just grab it so I can just grab it  from the session when I need it in the application?
0
 
LVL 18

Expert Comment

by:Gary Davis
Comment Utility
During the startup of the application (Global.asax.cs), I have occasionally iterated through all appSettings and store them in the Application object for easy access. Also, you could create a strongly typed class to hold them too (not quite as generic as using Application).

Gary Davis
0
 

Author Closing Comment

by:vbnetcoder
Comment Utility
ty
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now