100 Experience Points
An Adventure in Indie Game Development

Where Should User Files Go?

Over the weekend, I put out a new end-of-sprint release of my game. One key feature this included was that the game now saves your fleet between sessions. This is a really big deal, because now, for the first time ever, you can start building fleets that you’ll carry with you forever.

Today, though, I realized a fairly fatal flaw in what I had done.

Don’t panic, your ships are safe. For now.

The problem is that I’m saving my files in the same directory as the executable. I learned that this is a problem when I wiped out my obj and bin directories to make sure I was getting a complete rebuild. I killed my fleet. Actually, I killed two fleets, because I had renamed the fleet folder to start from scratch to make sure that was working.

All of that awesome ship design down the drain. Thrown into the Maw, never to do the Kessel Run again.

So basically, your game’s user files probably shouldn’t go into the same folder as the executable. Aside from the mistake I made, it could also cause problems when you put out a new update that shows up in a different directory, or overwrites the original one completely.

So the next question is, where should they go?

On the PC, where I’m making my game, I see three real candidates. Now interestingly, despite all of the C# programming that I’ve done, I never truly understood the differences between these three. I decided it was time to find out.

The first one is the My Documents or the Documents folder. This is a valid candidate. It’s where the user’s files are going. They know where to find it. Most users will know where to locate this directory if you tell them to go look in “My Documents” for something.

The other two are C:\Users[User Name]\AppData\Roaming and C:\Users[User Name]\AppData\Local. The thing about these folders is they’re quite a bit harder for the user to locate. Nobody knows what you’re talking about if you say, “Go look in your Roaming folder.”

Even better, the AppData folder is hidden by default. So on your typical game player’s computer, they won’t even be able to find it. So these folders are in kind of an obscure location. On the bright side, they’re not going to mess up the files unless they go out of their way to do so. The work required to hunt them down is equal to the trouble they could be in if they mess it up. Nothing will happen by accident. If they get to them, they get to them on purpose.

From the research that I’ve been doing this evening, here’s what I can tell you about the differences between these. All three of these are places to put user-specific files. The My Documents folder is where the user puts user-specific files. Which is why most people will save their Word documents, etc., in this directory. Because our game isn’t the user, this may not be where we want to put their data. (Unless they browse their computer to select the location.)

The other two, though, are where programs put user-specific data. The difference between Roaming and Local is that Roaming is for roaming user profiles. Roaming profiles feels very much like something that would happen at a large business where any user can log on to any machine. And let’s face reality, people aren’t playing your game at work. (Unless you build an awesome game, then they will be. Shh… don’t tell management. Them and their private offices, with their private bathrooms. It’s like, once you get promoted, you suddenly can tell people not to play games at work or something.)

But what this means is that the files that get dumped into Roaming will be copied off to their roaming profile, and if they log into a different computer, they’ll still have their files. The Local folder doesn’t do that. You can think of the Roaming folder as user-specific files, while Local is user- and computer-specific.

There are, of course, times where either of these are the right choice, but it looks like the most appropriate place for a game would be the Roaming folder. After all, roaming profiles is a Windows thing, and they take care of it all. It’s a feature our game picks up for free. So that’s where I’m dumping my files starting right now.

It’s worth pointing out that if you’re using C#, the paths for all three of these are easy to look up:

// The Local directory
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

// The Roaming directory
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

// The My Documents directory
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

One last note as it relates to people using my game. If you’ve already built a fleet in the game, you’ll be able to copy the UserFiles folder from the location by the .exe, and manually move them over to C:/Users/[User Name]/AppData/Roaming/Starbound Software/100XP/UserFiles. That should allow you to maintain your fleet moving forward.

Categories

2 Comments

Lexusjjss

27 March 2013 at 12:03 am

My preference would be “Documents\My Games\100XPGameOrWhatHaveYou\Ships”

Handy to get to if you want to make a backup of your data, and also not buried deep in AppData or Program Files.

RB Whitaker

27 March 2013 at 12:31 am

Lexusjjss… wow, you’re fast! I just barely posted this! I understand what you’re saying. In fact, that’s where I dumped my files at first. But then I had this strange thing where I already had a folder under the Documents folder for my game. I panicked for a second that I might have accidentally wiped out important files, like the source code. (Though it couldn’t have been too bad. It’s all in the repository.)

So that’s what kicked off this whole thing. I thought I should get to the bottom of where you’re supposed to put the files.

It really does sound like AppData is where Microsoft recommends putting it, but I could be convinced otherwise. Especially if it seems like the average user is going to want to crack open those files.

And of course, there’s always the option of defaulting to somewhere, and allowing the user to change it when they want.

Thanks for the feedback on this!