Discussion How to get exactly where Elite Dangerous saves the Status.json file

Currently I use essentially the following to get the Status.json path in my code:
C#:
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Saved Games", "Frontier Developments", "Elite Dangerous", "Status.json")

However I have a user with some customized user folder locations and Elite Dangerous is writing to a different drive than what I think my code returns for the path.
 
This is what I essentially copied and pasted from somewhere: (so don't as me to explain it in detail!)

 
This is what I essentially copied and pasted from somewhere: (so don't as me to explain it in detail!)

Thanks, I understand that, it's perfect. I didn't know about the SHGetKnownFolderPath function.

Basically from that code it looks like there's a system function SHGetKnownFolderPath that returns the paths to various "known folders". 4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4 is the unique id for the FOLDERID_SavedGames known folder.

The DllImport/extern are C# code to link to C/C++ DLL APIs, Shell32.dll being a system DLL. The MarshalAs is to turn the guid string into the struct that the native API expects. Though it almost looks like code is missing, not sure. The Marshal.PtrToStringUni is to turn a C string pointer to a C# string. The Marshal.FreeCoTaskMem is to free the memory used by that C string to avoid a leak. The 0x4000 flag is a "don't verify" flag I presume because the author had no need to know if the saved games folder existed or not.

Personally though I'd probably write a GetKnownFolderPath wrapper and actually listen to the return result and return null if the result is not S_OK.
 
Top Bottom