I currently have a FileHandler.cs
class which does various things with a file. The default directory for C# running within VisualStudio is Project/bin/Debug
or Project/bin/release
depending on which you are running. As such in the constructor of my file class I do the following:
System.IO.Directory.SetCurrentDirectory("..\\..\\TextFiles");
to go from either bin or debug to the main folder where I have my TextFiles
folder. The issue with this is the next time I create a FileHandler
the working directory goes up 2 more levels where TextFiles
doesn't exist.
How can I set the working directory to the default bin/debug again without using an absolute path?
There are several hacks I could use such as making it static or incremnting a counter for each FileHandler created and raising the current directory by 2 levels for each one past the first, but both those solutions are rather messy.
Thanks, Kalen