On Oct 18, 3:12 am, Albert Greinoecker <albert.greinoec....RemoveThis@uibk.ac.at>
wrote:
> ok, so just for clarification: there is no way to make a ASP.NET
> application look after a file located relatively to the application's
> current directory?
>
> The problem is: in my ASP.NET application,
> System.Envirmonment.CurrentDirectory points to c:\windows\System32, which
> does not make any sense...can this setting be modified?
>
> thx,
> Albert
You may want to ask questions in an ASP.Net dedicated forum for even
better responses, like at
www.asp.net
I don't see why you want something like Java's .properties file
when .Net has similar and/or better solutions.
For example, ASP.Net web.config's AppSettings node allows generic name/
value pair storage/retrieval with a single line of .Net code. Plus,
web.config natively supports encrypted (including custom encryption
protocol) property values, handy for storing database query/username/
passwords.
Other platforms like Java, PHP, and ASP makes one build all the basic
building blocks like storage, session state, connectivity, etc for a
Web Application, so one gets all anxious at writing code to do such
things. Be very happy that ASP.Net 2.0 is far better. It verifiably
allows you to drag-and-drop your way to developing more functional web
applications with up to 80% less code than every other platform
including ASP.Net 1.1.
Now, why would "System.Environment.CurrentDirectory" change to map to
the current directory of an application? That would be something like
Application.Environment.CurrentDirectory , which doesn't exist for a
good reason. By definition, a process has a single "current
directory", which is what System.Environment.CurrentDirectory returns,
but multiple web applications can share a single process for
execution, so there is no way to have a single value for "current
directory" work for all web applications like the way you imagine.
How you find the "current directory" of an application is to use
Server.MapPath(), which allows you to determine the absolute
filesystem pathname that maps to a given URL virtual name. You can
also use Request.ServerVariable to retrieve APPL_PHYSICAL_PATH (which
is legacy, IIS-related), or you can retrieve the SCRIPT_NAME or URL
server variables, diff between the two to determine the URL root, and
Server.MapPath that value. You have complete flexibility to do
"current application directory" and everything in between.
Personally, I think ASP.Net 2.0 makes it incredibly easy to write
incredibly sophisticated web applications with very little effort.
Thus, if you are thinking of something too complex or if you had to
spend too long thinking about a solution, there's probably a better
solution/implementation that already exists within ASP.Net or
someone's shared component.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
>> Stay informed about: IIS properties files