Yet another aspnet file path question
I'm going to have a folder of word document templates for a web app. I would like to use relative paths this time. When developing, I intend to use a subfolder in App_Data, but in some real configurations it will probably point to a network share.
Before reinventing the wheel, is there any built in method in aspnet (mvc) that gives a full path from:
- A web app relative path outside the web app folder
- A relative path within app_data
- A full path
The relative (or full) path is retrieved from appSettings if it matters.
Clarification: I'm wondering if there's a single built in method that can handle all of 开发者_高级运维theese cases as it's argument, not so much solutions for the separate cases.
A web app relative path outside the web app folder
You cannot have a relative path outside web app folder. Relative paths in ASP.NET are always relative to the root ~/
.
A relative path within app_data
var appData = Server.MapPath("~/App_Data");
var fullFilePath = Path.Combine(appData, "foo.txt");
A full path
you already have a full path
It seems the correct answer is "no".
精彩评论