Get File Path of A File In Your Current Project
c#
Solution
You could use `Path.Combine` and `AppDomain.CurrentDomain.BaseDirectory`:
string fileName = "SampleFile.txt";
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LocalConstants.EMAIL_PATH, fileName);
Returns in a test project in debug mode this path(when `LocalConstants.EMAIL_PATH="Emails"`):
C:\****\****\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsFormsApplication1\bin\Debug\Emails\SampleFile.txt
Problem
How do I programmically get the File Path of a File In my project? ``` string fileContent = File.ReadAllText(LocalConstants.EMAIL_PATH); ``` The EMAIL_PATH I added to my project as a text file. This line of code throws an exception because by default it is looking in the system32 folder for some reason. I need to set it to the projects directory.