Using server.mappath in classes (or not)
-
I can use Server.MapPath to find and read from files on my server; however I can only do this from within the code-behind for a web-page and not a separate class which gets compiled into the application dll. if I have function within this class/dll that wants to read from an xml file located in the same /bin folder, how do I do it? Is it just a matter of the right import statement in the class, or do I need to use another method altogether? OK, I could use server.mappath before calling the function and pass the full path as a parameter, but apart from that... thanks Fred
-
I can use Server.MapPath to find and read from files on my server; however I can only do this from within the code-behind for a web-page and not a separate class which gets compiled into the application dll. if I have function within this class/dll that wants to read from an xml file located in the same /bin folder, how do I do it? Is it just a matter of the right import statement in the class, or do I need to use another method altogether? OK, I could use server.mappath before calling the function and pass the full path as a parameter, but apart from that... thanks Fred
use using System.IO; // for C# Imports System.IO // for VB.NET and then try using Server.MapPath
Regards, Rashida Jabeen http://www.akaas.net[^]
-
use using System.IO; // for C# Imports System.IO // for VB.NET and then try using Server.MapPath
Regards, Rashida Jabeen http://www.akaas.net[^]
Thanks - but that doesn't work (which doesn't actually surprise me as "server" is not a member of system.io, as far as I can see...) In case it's not clear: I want to read a file from within a class module (as opposed to a code-behind module of a webapge) cheers F
-
Thanks - but that doesn't work (which doesn't actually surprise me as "server" is not a member of system.io, as far as I can see...) In case it's not clear: I want to read a file from within a class module (as opposed to a code-behind module of a webapge) cheers F
its working fine at my side i m using it in a code class file (i.e. a data access class) not code behind file and it is working
Regards, Rashida Jabeen http://www.akaas.net[^]
-
its working fine at my side i m using it in a code class file (i.e. a data access class) not code behind file and it is working
Regards, Rashida Jabeen http://www.akaas.net[^]
Well, I don't know. Thanks for ytour answer, but in my environment (VS2003) it simply doesn't recognise server.mappath within a class module.... remind me not to visit your akaas.net site again!! I lost count of the unwanted popups offering to install this that and the other... nothing turns me off a site faster than that! Didn't get past the first page but closed them all down as fast as I could.... cheers Fred