Question

I created a game in C# XNA using simple file IO to handle saving game data, however this creates a problem when I package my game and have someone else run it. After a few tests, I found out the game could be run in Administrator, however would throw UnauhorizedAccessExceptions when not done so (And simply hang unresponsive when not caught). This does make sense to me, as I remember seeing this exception back when I was experimenting with the File IO.

I could simply catch the exception and do nothing with it, leaving the game itself responsive... but saving functionality non-working unless run with Admin privileges.

So my question is, is there a place I can save to that isn't user intrusive, but accessible without Administrator access? Is this even a matter of an accessible locations or something more? Is there any decent way around this at all? If I need to provide code or any more specifics please let me know.

Was it helpful?

Solution

Somewhere inside the user profile, for example AppData or My Documents.

Get the path to AppData as follows:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Documentation for Environment.GetFolderPath is here:

http://msdn.microsoft.com/en-gb/library/system.environment.getfolderpath.aspx

OTHER TIPS

Where are you trying to save the files?

Depending on what you want to save, I would say saving to ApplicationData is a good bet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top