Created
October 25, 2013 15:33
-
-
Save csharpforevermore/7156614 to your computer and use it in GitHub Desktop.
ASP.NET - get relative path to files in a specific folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IEnumerable<string> GetRelativePathsToRoot(string virtualPath, string filter) | |
{ | |
var physicalPath = Server.MapPath(virtualPath); | |
var absolutePaths = Directory.EnumerateFiles( | |
physicalPath, | |
filter, | |
SearchOption.AllDirectories | |
); | |
return absolutePaths.Select( | |
x => Url.Content(virtualPath + x.Replace(physicalPath, "")) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment