473,327 Members | 2,112 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,327 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 1704
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.