I'm reading and writing to some text files and I'm currently using a set path. How can I change that set path to use the same folder where the executable resides?
For example:
File.ReadLines(@"D:\Users\MyUserName\Desktop\MyApplication\names.txt").Skip(1).ToList();
and...
File.WriteAllLines(@"D:\Users\MyUserName\Desktop\MyApplication\names.txt", lines);
and...
using (StreamWriter writer = new StreamWriter(@"D:\Users\MyUserName\Desktop\MyApplication\names.txt", true))
{
writer.WriteLine(myText);
}
It also needs to work when testing in the IDE (Visual Studio).