Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class YOUR_CLASS_NAME {
- private readonly IHostingEnvirounment _hostingEnvirounment;
- public YOUR_CLASS_NAME(IHostingEnvironment hostingEnvironment)
- {
- _hostingEnvironment = hostingEnvironment;
- }
- public Image GetImageFromContentRoot(string name) {
- // e.g.: imgPath = "D:\Hosting\ProjectFolder\beep.png"
- var imgPath = Path.Combine(_hostingEnvirounment.ContentRootPath, name);
- return Image.FromFile(imgPath);
- }
- }
- public Image GetImageFromWebRoot(string name) {
- // e.g.: imgPath = "D:\Hosting\ProjectFolder\wwwroot\beep.png"
- var imgPath = Path.Combine(_hostingEnvirounment.WebRootPath, name);
- return Image.FromFile(imgPath);
- }
Add Comment
Please, Sign In to add comment