Don’t use Server.MapPath. It’s slow. Use this instead, HttpRuntime.AppDomainAppPath
. As long as your web site is running, this property is always available to you.
Then use it like this:
string filePath = Path.Combine(HttpRuntime.AppDomainAppPath, "email/teste.html");
More Related Contents:
- What is a NullReferenceException, and how do I fix it?
- C# elegant way to check if a property’s property is null
- Value cannot be null. Parameter name: source
- Checking if an object is null in C#
- Avoiding null reference exceptions
- Initializing list property without “new List” causes NullReferenceException
- Auto Log Off when opening specific folder (Homework)
- JSON.net: how to deserialize without using the default constructor?
- Find a string between 2 known values
- How do I get all instances of all loaded types that implement a given interface?
- How do I use Assert to verify that an exception has been thrown?
- How to determine if a type implements an interface with C# reflection
- Async process start and wait for it to finish
- Can you configure log4net in code instead of using a config file?
- Formatting numbers with significant figures in C#
- How do I print WebView content in a Windows Store App?
- Enumerating through an object’s properties (string) in C#
- JIT compiler vs offline compilers
- What is the best way to get the executing exe’s path in .NET?
- Finding a subsequence in longer sequence
- When is “using” block used for in C#? How to use “using” block in C#?
- How to pass multiple parameters to a get method in ASP.NET Core
- How to use LINQ Distinct() with multiple fields
- How can I get the icon from the executable file only having an instance of it’s Process in C#
- Should i use ThreadPools or Task Parallel Library for IO-bound operations
- When is it appropriate to use the KnownType attribute?
- Reading data from DataGridView in C#
- json add new object to existing json file C#
- Why it is not possible to define generic indexers in .NET?
- C# – What does “\0” equate to?