I'm building an executable application from WPF in visual studio, and I have a local text file added to the project (StringList.txt) that I'm trying to read into a List object. What would the path for that file be for a StreamReader such that the executable can access the file when I deploy it and run in on another computer?
So far I have:
List<String> list = new List<String>();
StreamReader sr = new StreamReader("~/Desktop/Deploy/StringList.txt");
String line = sr.ReadLine();
while (line != null)
{
fields.Add(line);
line = sr.ReadLine();
}
sr.Close();
**Deploy is the publish folder location
The
~/Desktop/Deploy/StringList.txt
wont work for WPF.. Try this:This will open the file within a subdirectory of your program.