GetFilesInVirtualDirectory

 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.
}

Description

This extension method acts similarly to Directory.GetFiles except that the directory path is expressed as a virtual directory.

Details

Double click on the code to select all.

 

;