Adding Game Data Files to Title Storage

Describes how to add game data files to the title storage location.

Tip

This topic describes how to add files to title storage that the game will access through stream I/O. This is the exceptional case, and is not recommended for most XNA Game Studio games. Instead, consider using the Content Pipeline to manage your game data most efficiently.

Adding files to Title Storage

Any file that your game needs at runtime can be added to the title storage location simply by adding the file to the root-level of your project in Visual Studio.

To add a data file to title storage

  1. Copy the file to your project directory.

  2. In Solution Explorer, right-click the project name, select Add, and then click Existing Item.

    Ff434501.Storage_AddExistingItemMenu(en-us,XNAGameStudio.41).png

    The Add Existing Item dialog box appears.

  3. In the file types drop-down list, ensure the default setting of All Files (*.*) is selected.

    Ff434501.Storage_AddExistingItemDlg(en-us,XNAGameStudio.41).png

  4. Select the name of the file you want to add to the project from the list, and then click Add.

    An entry for the file appears in your project in Solution Explorer.

  5. In Solution Explorer, click the file just added to view its properties. If the Properties window is not open, right-click the file name, and then click Properties.

  6. In the Properties window, change Build Action to None, and change Copy to Output Directory to Copy if newer.

    Ff434501.Storage_FileProperties(en-us,XNAGameStudio.41).png

The file now can be accessed by passing its name to TitleContainer.OpenStream as described in Reading Game Data from Title Storage.

Note

You can add data files to a subfolder in your project, but you will need to refer to the subfolder name when accessing the content with OpenStream. For example, if you place a file named data.txt in a GameData folder in your project, you'll pass the string GameData/data.txt to OpenStream.

See Also

Tasks

What Is Storage?
Reading Game Data from Title Storage

Reference

TitleContainer