I have problem with my C# app, when is opened via file association, it works in file directory. For example, when I create copy of opened file:
File.Copy("C:\Photo\car.jpg", ".\car2.jpg"); // this is only ilustration code.
It makes new file "C:\Photo\car2.jpg", but I want to make file in my app directory (".\car2.jpg").
So, I think, when app is opened via file association, it run with working folder of that file ("C:\Photo\"). Is there way, how to keep working directory as directory with app.exe?
Edit:
This is not solution, I need to get equals of ".\" and System.AppDomain.CurrentDomain.BaseDirectory:
File.Copy("C:\Photo\car.jpg", Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "car2.jpg"));
I have to use this on many places in application, solution can be sets:
Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
but I prefer set it in startup application via file association and not in running program - it looks cleaner.
Thanks, Jakub