Read files from a Folder present in project
it depends where is your Data folder
To get the directory where the .exe file is:
AppDomain.CurrentDomain.BaseDirectory
To get the current directory:
Environment.CurrentDirectory
Then you can concatenate your directory path (@"\Data\Names.txt"
)
below code should work:
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Data\Names.txt");
string[] files = File.ReadAllLines(path);