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
2 answers
Server.MapPath returning a path with a folder that doesn’t exists
I have following code:
var dir = @"Content\Posts\" + yr + @"\" + mnth + @"\";
var a = Path.Combine(dir, dy.ToString() + pId.ToString() + ".txt");
//a contains: "Content\\Posts\\2013\\8\\file01.txt"
stts = obj.NotifyMail(title, writeup,…

Maven
- 14,587
- 42
- 113
- 174
1
vote
2 answers
Server.MapPath gives error with UNC
Here is my directory to my server (permissions are good):
string ServerPath = ("\\\\servername\\Public\\Intranet2007Docs");
Here I am accessing it:
DirectoryInfo directory = new DirectoryInfo(Server.MapPath(ServerPath));
And here is the error:…

rainhider
- 49
- 1
- 4
- 13
1
vote
2 answers
Write a Server.MapPath in the web.config file?
Hi there i'm trying to write log for my live website and am having problems with my paths, I need to use the method Server.MapPath but i need it done in my web.config.
How would i go about this?
The file value holds the path, but i need to set a…

Pomster
- 14,567
- 55
- 128
- 204
1
vote
1 answer
Server.MapPath and window.open()
I'm actually working on an app that provides the possibility to the users to upload the files they wish. Those files should also be visualizable once uploaded.
In order to do that I'm trying to get the file path with Server.MapPath and a…

Cristobal Bonaquista
- 11
- 1
- 3
0
votes
4 answers
how to upload excel with duplicate name
how to upload excel file with duplicate name file but its don't do overwrite the previous name file.
So if i upload the file with same name it will saving like windows do.
ex. firstly i upload excel file = "fileExcel". then i upload again with same…

tyo
- 67
- 1
- 2
- 13
0
votes
3 answers
Server.MapPath in ASP.Net
I have developed a Web Application using ASP.Net with Microsoft Access as database. Now i have connected to the database using OleDB connection. The problem is when i give the database source in Connection String Source="C:/WebApp/DB/data.mdb". The…

Kishore Kumar
- 12,675
- 27
- 97
- 154
0
votes
1 answer
How can I save image file to web app through web service project?
I have 2 projects: one is a web service project and other is a web app project. I have to upload an image file from web service and save the same image in a folder in web app project. The file path is stored in the database and image itself is…

Amit Kaushal
- 41
- 6
0
votes
2 answers
Accessing file in main domain folder from subdomain app
I have a web app in a subdomain, where I want to uptain access to a file located in the main domain. Is that possible?
HttpContext.Current.Server.MapPath("../www/file.xml"));
Where "www" in the main folder. The "../" doesnt work.
To be crystal…

Kasper Skov
- 1,954
- 10
- 32
- 53
0
votes
1 answer
Server.MapPath returns a different value than I expected
In our ASP.NET application, we use this code:
Server.MapPath("/") = C:\myappsFolder\myapp\web\
But, how come Server.MapPath("/Token") returns the following ?
Server.MapPath("/Token") = C:\myappsFolder\myOtherFolder\myapp\tkn
I would think…

faujong
- 949
- 4
- 24
- 40
0
votes
1 answer
How to read a relative web path with Server.MapPath with space character in filename or path in C#
What i get is
src = Request.QueryString["imgsrc"];//src = "images/file 15.jpeg";
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(src));
the second line returns System.IO.FileNotFoundException cause of the space in the…

dtakis
- 571
- 1
- 9
- 30
0
votes
1 answer
Is there a universal MapPath function for both client-side and server-side apps?
What is the universal MapPath equivalent to the below? Universal, meaning, that I could use it in both client-side and server-side .NET apps, not just in server-side apps.
System.Web.Hosting.HostingEnvironment.MapPath(virtualPath)
The reason I'm…

Andy
- 2,670
- 3
- 30
- 49
0
votes
1 answer
ASP,NET MVC change a virtual path to a physical path when uploading a file
I need to save the files somewhere else because the server that this application is getting full
How would I change the virtual path to a physical path?
This is my original controller
[HttpPost]
[ValidateAntiForgeryToken]
…

AllMuch
- 29
- 7
0
votes
1 answer
How to specify a local file path for a user outside of a web application's directory?
I am creating an ASP.NET MVC web application that serializes JSON files for user-inputed information. The base template that I was following operates like this:
string jsonData = JsonConvert.SerializeObject(rootObject);
string path =…

C Murphy
- 47
- 1
- 13
0
votes
1 answer
Fail to use IHostingEnvironment to get path
I'm creating project api in .Net Core 2.1, in my startup.cs, I added:
services.AddSingleton();
After that, reate IPathProvider interface and class:
public interface IPathProvider
{
string MapPath(string…

Đồng Vọng
- 159
- 3
- 11
0
votes
1 answer
Server.MapPath with query string in ASP.NET MVC
After some 15 mins of Goooooogling, I cannot find a solution to this simple problem. So some little help?
The application is hosted in a web subfolder of the website, I need to map a relative Uri (which is a Hello action in the RouteController which…

kennyzx
- 12,845
- 6
- 39
- 83