0

string strMailTemplatePath = HttpContext.Current.Server.MapPath("~/EmailTemplate/HODEmailTemplate.html");

This is the code I have written for reading file path. But I'm getting the below mentioned error.

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Please help me to read the file path.

  • Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – shingo Mar 15 '23 at 06:51
  • shingo, thank you for the reply. From this I'm unable to get any proper answer. – Edwin K Biju Mar 15 '23 at 06:55

1 Answers1

0

I think AppDomain.CurrentDomain.BaseDirectory is what you are looking for.

var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EmailTemplate", "HODEmailTemplate.html");

See more about : MSDOC

AVTUNEY
  • 923
  • 6
  • 11