string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
Gives an exe directory. Therefore, using this with Path.Combine will give the desired result:
string filenamelocation = System.IO.Path.Combine(path, "filename.txt");
source
share