I recently found out that windows will not let applications write directly into the applications directory if it is located in ProgramFiles instead it remaps the saved files to a virtual directory location.
This is a problem as my players find it difficult to locate their saved games files.
What I want to do is save in the correct location under the Userprofile environment variable but I have been unable to work out how to derive the correct path.
Have you tried path variables in Application class ? I’m pretty sure they have that covered. Something like persistDataPath, if my memory serves. It might be safer.
If you want this to work cross-platform, you should use the SpecialFolder setup. For this case I would recommend using .ApplicationData or .Personal. Use Path.Combine to join the path elements together. Its implementation is a bit stupid though, so I usually set up a utility method like this:
public static string CombinePath (string first, params string[] others)
{
foreach (string element in others)
{
first = Path.Combine (first, element);
}
return first;
}
Let’s you splice multiple elements together in one call, ex: