Colleagues, I have the following problem: I need to access files of different types (images, pdfs) that are within the solution of my project. I tried to use Server.MapPath
but it throws an exception, which mentions that HttpContext.Current
is null.
I tried Path.Combine(Environment.CurrentDirectory, @"img\logo.png")
and it returns a route pointing to the local disk, but it's not what I need.
Deputy code extract:
if(condicion)
{
string pathPdf = Path.Combine(Environment.CurrentDirectory, @"img\logo.png");
emailService.AttachFile(pathPdf);
}
Basically it is a service that sends an email with an attachment when a condition is met.
Any ideas on how to fix it?