Solved

UPLOAD file path in webconfig

Posted on 2011-03-11
4
740 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
[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
4 Comments
 
LVL 5

Accepted Solution

by:
mayankagarwal earned 500 total points
ID: 35114589
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
ID: 35115539
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
ID: 35115948
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
ID: 35160989
ty
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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