.net – c# get path for directory in project

.netasp.netc#-4.0

I'm trying get the path of a folder in my project called EmailAttachments. I tried

File.Exists("~/EmailAttachments/TestReport.pdf")

but that returns false. How can I get the path to a directory in the program so I can write files to it and retrieve them later?

This is in asp.net, not winforms

Best Solution

If you're trying to get the ASP.NET local path, use Server.MapPath("~/EmailAttachments/TestReport.pdf") to get its fully qualified path.