GetFilesInVirtualDirectory
This extension method acts similarly to Directory.GetFiles except that the directory path is expressed as a virtual directory.
Source
public static IEnumerable<string> GetFilesInVirtualDirectory(this Page targetPage, string directoryPath)
{
return Directory.GetFiles(targetPage.Server.MapPath(directoryPath)).Select(f => Path.GetFileName(f));
}
Example
foreach (var file in GetFilesInVirtualDirectory("../Images")
{
// Do something interesting.
}