I want to get the file path from a folder/subfolder inside a folder and populate it to a image attributes. using HttpContext.Current.Server.MapPath(@"~\StorageFolders");
will return full path and will return
Not allowed to load local resource
.
So now i am using looping and replacement method. Am i doing i right? or can i just get the full path excluding root folder example : the function returns
C:\WebsiteRootFolder\Myfolder\SubFolderA\handsome.png
to relative
Myfolder\SubFolderA\handsome.png
always return to the root folder of the website
var fileList = Directory.GetFiles(path, "*", SearchOption.AllDirectories).ToList();
var rootpath= HttpContext.Current.Server.MapPath("~");
foreach (var item in fileList)
{
string s = item.Replace(rootpath, "");
Image image = new Image();
image.ImageUrl = ResolveUrl(@"~\"+ s);
//continue of codes
}