I’m building a class library which references a file in its working directory. However, it’s unable to find the file because it keeps looking in C:\Program Files\Visual Studio 2010\Common7\IDE\. The solutions is not in that directory, nor is the working directory set to that. I can’t see anything related to my class library in that folder either!
This happens whether I use Environment.CurrentDirectory or not, when constructing my file path.
Does anybody know why it might be doing this?
From the sounds of it you want to be using
Application.StartupPathwhen constructing your file path so something along the lines of;If you want to set the current directory to the right directory (although personally I would recommend using the
Application.StartupPathrather than trust the current directory will be right) you can do this;As for why, I’ve had occasions where you do something like open a file open dialog then navigate to another location, which then becomes the current directory.