petros
petros

Reputation: 715

WPF Text file in solution, not Debug directory

I created txt file and added it to my solution in "Text" directory. I tried to read it using:

string[] lines = File.ReadAllLines("Text\t.txt");

but it says that there's not any file "Text\t.txt" in Debug directory. I want to have all files in solution. How can I solve it?

Upvotes: 0

Views: 113

Answers (1)

Adi Lester
Adi Lester

Reputation: 25211

Right click on that file in the solution explorer and select Properties. Then make sure that Build Action is set to None and that Copy to output directory is set to Copy Always

Also make sure that you escape the \ character:

string[] lines = File.ReadAllLines("Text\\t.txt");

Upvotes: 1

Related Questions