¿Qué debo hacer para que Server.MapPathfuncione?
yo tengousing System.Web;
¿Qué más? Cuando escribo, Serverno hay una opción de resultado rápido (intelli-sense) para Server.
¿Alguna ayuda?
c#
visual-studio
intellisense
server.mappath
a1204773
fuente
fuente

Respuestas:
puedes intentar usar esto
o usar
HostingEnvironment.MapPathfuente
Su proyecto necesita hacer referencia al ensamblaje
System.Web.dll. El servidor es un objeto de tipoHttpServerUtility. Ejemplo:fuente
System.Web.HttpContext.Current.Server.MapPath("~/")da nulo si lo llamamos desde un hilo.Entonces, intente usar
System.Web.Hosting.HostingEnvironment.MapPath("~/")fuente
Primero agregue una referencia a
System.web, si no la tiene. Hazlo en la carpeta Referencias .Luego puedes usar
Hosting.HostingEnvironment.MapPath(path);fuente
fuente
Intente agregar
System.Webcomo referencia a su proyecto.fuente
Necesita agregar reference (
System.Web) Reference a System.Webfuente
Sé que esta publicación tiene algunos años, pero lo que hago es agregar esta línea a la parte superior de su clase y aún podrá utilizar Server.MapPath
O puedes hacer una función
Mi objetivo es facilitar las cosas. También lo he agregado a mi clase de Utilidades en caso de que me vuelva a encontrar con esto.
fuente