Search code examples
c#asp.netimageapp-themes

c# access an image in app_themes folder


I have an image in my App_Themes/Default folder that I want to load into a byte array. However I am having issues getting to the file. Is there any easy c# way to do this?

My solution looks like this:

-Project
-App_Themes
-Default
-image1.png


Solution

  • You can use Server.MapPath() to get the full local file path for a relative url, for example:

    string lFileName = Server.MapPath("~/App_Themes/Default/xyz.png");