Config question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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-us/cpref/html/frlrfsystemwebhttpserveru
tilityclassmappathtopic.asp?frame=true

#Server.MapPath
http://msdn.microsoft.com/library/en-us/iissdk/iis/ref_vbom_serommp.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
 
Thank you Steven

I see I can use Request.MapPath or System.Reflection.Assembly.GetExecutingAssembly.Location 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
 
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
 
Back
Top