1

For example my app is in C:\Root\App then I have my images from C:\Image folder

C:\Image is configured in the web.config and getting the absolute path of this folder will result in file:////C://Image

is there a way to convert this to ../../Image that is relative to C:\Root\App folder?

or is there anyway to display images outside the app folder in a tag? ..because

3
  • Why not just move the image directory inside the app root? It would make deployment to a server far easier Commented Dec 4, 2013 at 8:20
  • @levelnis: I don't know about evilom's reasons, but the fact is that manipulating the file system below your application root can cause app domain reload (such as when you move files, delete directories or after creating a few files). It's also good practice to put "heavy" files away from those that need quick access. It could also be about disk partitioning, disk space, disk speed... Commented Dec 4, 2013 at 8:22
  • @levelnis aside from Luaan's reasons, I also need to access the files from a different site hosted in the same server. Commented Dec 4, 2013 at 9:19

1 Answer 1

1

Basically, you've got three ways:

  1. Use a file system solution - Create a hardlink in your application directory that points to C:\Image. Everything should work just fine.
  2. Add a new virtual directory ("Images") in your application directory, that points to C:\Image.
  3. Create your own HttpModule / HttpHandler to server the files from your C:\Image directory.

I can write more about any of these solutions if you'd like.

Sign up to request clarification or add additional context in comments.

1 Comment

I am also thinking to stream the files using an absolute path as my last resort. But I found Luaan's solution #2 more convinient. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.