Get path in DLL rather than from ASP.NET
-
Hi, My ASP.NET page calls a method in a separate DLL. In the DLL it opens an XML file but when I run it, it can't find the XML file because it's looking in the wrong place I think. If it was code-behind on an ASP.NET page I'd just use Server.MapPath() to locate the XML file but how can I do it in the DLL method my ASP.NET page calls? Thanks :)
-
Hi, My ASP.NET page calls a method in a separate DLL. In the DLL it opens an XML file but when I run it, it can't find the XML file because it's looking in the wrong place I think. If it was code-behind on an ASP.NET page I'd just use Server.MapPath() to locate the XML file but how can I do it in the DLL method my ASP.NET page calls? Thanks :)
Have you considered passing the path as a parameter to the method that you're calling? That would allow you to map the path in your ASP.NET page and pass the fully qualified path to your library. Hope that helps. :)
--Jesse
"... the internet's just a big porn library with some useful articles stuck in." - Rob Rodi
-
Hi, My ASP.NET page calls a method in a separate DLL. In the DLL it opens an XML file but when I run it, it can't find the XML file because it's looking in the wrong place I think. If it was code-behind on an ASP.NET page I'd just use Server.MapPath() to locate the XML file but how can I do it in the DLL method my ASP.NET page calls? Thanks :)
Try taking a look at the System.Environment class. It has a method CurrentDirectory() which returns the current working folder. You can also try Application.StartupPath.