You can do
string assemblyPath = Assembly.GetExecutingAssembly().Location; string assemblyDirectory = Path.GetDirectoryName(assemblyPath); string textPath = Path.Combine(assemblyDirectory, "MyFiles", "Test.txt"); string text = File.ReadAllText(textPath);
... just smash it ... but you could write it all on one line, not to mention the need ...
alternatively, if your Environment.CurrentDirectory is already installed in the directory of your build site for execution, you can simply do
File.ReadAllText(Path.Combine("MyFiles", "Text.txt"));
source share