I set my C# application to auto-run on start up though the registry.
The issue is that when that:
Environment.CurrentDirectory //returns C:\Windows\System32
Instead of the file’s actual location.
Why is it causing this and is there an alternative?
Im using ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Current Version\Run’
CurrentDirectoryis not the location of your program; it’s the folder that the program was started in. (although it can change later)You’re looking for
Path.GetDirectory(typeof(YourType).Assembly.Location)