Server.MapPath problems

  • Thread starter Thread starter Daniel Groh
  • Start date Start date
D

Daniel Groh

Hi Joe, no it's not static...yes..it's static when u have a webapplication
and i have a class library application, try it and tell me, may be could be
a problem in my framework lib u know ? but i don't think so!

As I told, i tryed to import the namespace HttpServerUtility but didn't work
=(

Tks Joe!

Daniel

------------------------------

Hi Joe

Hi Daniel,

It's static. Try Server.MapPath("XMLErrors.xml")

Joe
--
http://www.csharp-station.com
Hi, I'm trying to use the Server.MapPath in my ClassLibrary application,
but I didn'get it...I tryed already the System.Web.HttpServerUtility...

OpenConn();
DataSet dsErrorSQL = new DataSet();
HttpServerUtility myPath = new HttpServerUtility();
dsErrorSQL.ReadXml(myPath.MapPath("XMLErrors.xml"));
and i have this error:

No overload for method 'HttpServerUtility' takes '0' arguments

Wich namespace should i import ?

Thank you folks!

Daniel
 
Daniel Groh said:
Hi Joe, no it's not static...yes..it's static when u have a webapplication
and i have a class library application, try it and tell me, may be could be
a problem in my framework lib u know ? but i don't think so!

As I told, i tryed to import the namespace HttpServerUtility but didn't work
=(

I'm not sure that you will be able to access the Server object from
within your dll. If you are going to run the dll within an aspnet
process, maybe the calling code could pass in a reference?
 
Steve Walker said:
I'm not sure that you will be able to access the Server object from within
your dll. If you are going to run the dll within an aspnet process, maybe
the calling code could pass in a reference?

Hrm...

HttpContext.Current.Server.MapPath("filename")

:)

HOpe that helps ;)

Mythran
 
Hrm...

HttpContext.Current.Server.MapPath("filename")

Didn't know about that. Handy. Presumably Current will be null if he
isn't running his assembly in process with an aspnet app?
 
Steve Walker said:
Didn't know about that. Handy. Presumably Current will be null if he isn't
running his assembly in process with an aspnet app?

AFAIK, Correct ;)

Mythran
 
Hi Guys, It's working...

using System.Web.UI;

and later

System.Web.HttpContext.Current.Server.MapPath("xmlErrors.xml");



=D



Thank u all!
 
Daniel Groh said:
Hi Guys, It's working...

using System.Web.UI;

and later

System.Web.HttpContext.Current.Server.MapPath("xmlErrors.xml");



=D



Thank u all!

try:

using System.Web;

HttpContext.Current.Server.MapPath("xmlErrors.xml")

Shorter ;)

Mythran
 
Back
Top