I've been adding features to EDDI for the journal and one question was how to find the "Saved Games" directory. Looks like the following code does the job. Feel free to copy it or to fix it if you find there are any problems with it.
Code:
private static string GetSavedGamesDir()
{
IntPtr path;
int result = SHGetKnownFolderPath(new Guid("4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4"), 0, new IntPtr(0), out path);
if (result >= 0)
{
return Marshal.PtrToStringUni(path) + @"\Frontier Developments\Elite Dangerous";
}
else
{
throw new ExternalException("Failed to find the saved games directory.", result);
}
}
[DllImport("Shell32.dll")]
private static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)]Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr ppszPath);