473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Config question

Forgive me. This may be a dumb question but I haven't found the answer yet.
What configuration setting do you change/set to determine where .Net looks for files when no specific path is specified. Specifically I mean files and not assemblies. For example my application may open a .xml file or a .xsl file. By default .Net looks for these files in my winnt/system32 folder. I want to change where .Net looks for these files to say the /bin folder of my app.

Any and all help is greatly appreciated!
Morgan
Nov 18 '05 #1
3 1712
Hi Morgan,

As for the problem that some times the .NET will looks for these files in
system32 folder, this is because when you using some dotnet apis they will
call some system api internally which will mapping the current path(haven't
specified path) to the system32(their dll's path). In web application, we
can use the Server.MapPath or
Response.MapPath to mapping the current web context's virutal path to
physical path on the server's disk, for example:

Response.Write("<br>Current path: " + Request.MapPath("./"));
Response.Write("<br>Site Root path: " + Request.MapPath("/"));
Response.Write("<br>Application Root path: " + Request.MapPath("~/"));
Response.Write("<br>Current's Parent path: " + Request.MapPath("../"));

For more detailed information on the "MapPath" method, please refer to the
following link in MSDN:
#HttpServerUtility.MapPath Method
http://msdn.microsoft.com/library/en...webhttpserveru
tilityclassmappathtopic.asp?frame=true

#Server.MapPath
http://msdn.microsoft.com/library/en...rommp.asp?fram
e=true

Hope helps. Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #2
Thank you Steven

I see I can use Request.MapPath or System.Reflection.Assembly.GetExecutingAssembly.Lo cation in my non-web apps. I had thought that perhaps there was a setting in the machine.config or web.config files I could change that would effect the default path for files

Thank you
Morgan
Nov 18 '05 #3
Hi Morgan,

Thanks for the followup. As far as I know, there is a static method of the
Directory class :
#Directory.SetCurrentDirectory Method which can set the currenty directory.
But have no idea on a element to set this in the application's
configuration confige file. Also, I still think the problem that sometimes
it'll look for files in the SYSTEM32 folder is caused by the certain
component's native dll is in the system32 folder. In other word, if call a
method with a no specified full path filename in your own component, it'll
look for the file in the directory where your own dll is located.

Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chinmoy Mukherjee | last post by:
Hi All, I have a config file as followings IP_ADDR=1.2.3.4 PORT=1290 IP_ADDR=1.2.3.5 PORT=1291
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
6
by: Rich | last post by:
Hello, I picked up this example on using the Reflection namespace for loading forms/classes on the fly at msdn http://msdn.microsoft.com/library/default.asp?...
5
by: Dean Slindee | last post by:
I store several application settings in the project's "app.config" file. I also have a form that reads these values and displays them in a listview so that the user can adjust them. My question...
11
by: TARUN | last post by:
Hello All I need to ask about the configuration file in .NET, There are Two config File 1. Web Config 2. Machine config I understand the the usage of Web config , but not able to understand...
5
by: Keith | last post by:
Hello all, I have a C# Windows Forms app. It is in namespace App.GUI. It builds to Nav.exe. I have entered an application level setting using the designer. Its type is string, name is "FOO"...
5
by: mark_overstreet | last post by:
I have a generic data layer DLL that expects to read its connection string from it's own config file. The dll and config file have been placed in the bin directory (VS.NET2005). However, due to...
1
by: =?Utf-8?B?Y2FsZGVyYXJh?= | last post by:
Dear all, I am developing a multi tiers application and actually responsible of delivering the buines logic library. That buisnes logic library will need some parameters to be suitebale...
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
10
by: eagle | last post by:
I have a web.config in my application that contains the connection strings to all my datasources. I want to move these connection strings to another web config up the folder hierarchy so that all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.