Carl R
Carl R

Reputation: 8214

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:

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.

Upvotes: 0

Views: 200

Answers (2)

Carl R
Carl R

Reputation: 8214

It seems the correct answer is "no".

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1038780

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

Upvotes: 3

Related Questions