The Server.MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.
Questions tagged [server.mappath]
131 questions
1
vote
1 answer
System.UnauthorizedAccessException loading file from Disk
Really weird problem loading a file from disk:
string path = HttpContext.Current.Server.MapPath("~/Datasets/blob.xml");
FileStream stream = new FileStream(path, FileMode.Open);
Throws exception:
An exception of type…

user648490
- 41
- 3
1
vote
3 answers
How can I use Server.MapPath to upload a file onto a server which is mapped on my computer
So far I know how to upload a file to a folder within my solution using the code below.
string root = HttpContext.Current.Server.MapPath("~/upload");
How can I save the file to a different location that is not within a solution i.e to a server…

Junta
- 23
- 4
1
vote
1 answer
Server.MapPath C# works locally but not from server
having a big of an issue with with Server.MapPath in that I can't get it to resolve from server and unsure how to test what it's trying to do.
Locally, it works fine in a whole variety of different ways, but when I put it up to the server, each and…
user7528326
1
vote
2 answers
Map path in Quartz.net in ASP.NET & C#
I am using Quartz.Net in Asp.Net C# to schedule my task. I want to write to a file, when I try without the MapPath it's writing to the file as expected (Hello world).
Here is the code what I wrote. I have tried HostingEnvironment.MapPath and…
user4576114
1
vote
1 answer
Server.MapPath not working
I'm trying to access files in a virtual directory I created in IIS for the first time but am getting weird results.
OS: Windows XP Pro
IIS: 5.1
Development Platform: Visual Studio 2008
Language: C#
Virtual Directory Name: portal
Local Path:…

Jeremy
- 45
- 3
- 9
1
vote
1 answer
server.mappath resolve referenced file path to relative dir
In my mvc application, I'm trying to serve an html page like this
return File(Server.MapPath("~/Documentation/" + decoded["version"].ToString().Trim() + "/" + "index.htm"), "text/html");
The entry point index.htm includes some js scripts.