I have an assmebly that will be used in both a desktop app and an asp.net website.
I need to deal with relative paths (local files, not urls) in either situation.
How can i implement this method?
string ResolvePath(string path);
Under a web envronment, id expect the method to behave like this (where d:\wwwroot\mywebsite
is the folder iis points at):
/folder/file.ext => d:\wwwroot\mywebsite\folder\file.ext
~/folder/file.ext => d:\wwwroot\mywebsite\folder\file.ext
d:\wwwroot\mywebsite\folder\file.ext => d:\wwwroot\mywebsite\folder\file.ext
for a desktop environment: (where c:\program files\myprogram\bin\
is the path of the .exe)
/folder/file.ext => c:\program files\myprogram\bin\folder\file.ext
c:\program files\myprogram\bin\folder\file.ext => c:\program files\myprogram\bin\folder\file.ext
I'd rather not inject a different IPathResolver
depending on what state its running in.
How do I detect which environment I'm in, and then what do i need to do in each case to resolve the possibly-relative path?
Thanks