문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top