Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:50:57+00:00 2026-05-31T12:50:57+00:00

I’m creating an Xbox application and I have this problem with the content pipeline.

  • 0

I’m creating an Xbox application and I have this problem with the content pipeline.
Loading .xnb files is not a problem but I can’t seem to find any helpful tutorials on writing via the content pipeline. I want to write an XML whenever the user presses a custom made "save" button.
I’ve searched the web for "saving game sate" etc. but so far I haven’t found a solution for my case.

So, summarized: is there a way to write data (in XML format) via the content pipeline, if my Save() method is called?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:50:59+00:00Added an answer on May 31, 2026 at 12:50 pm

    Saving and loading during an XNA game involves a series of asynchronous method calls. You’ll find the objects you need in the Microsoft.Xna.Framework.Storage namespace.

    Specifically, you need a StorageDevice and a StorageContainer;

    private static StorageDevice mStorageDevice;
    private static StorageContainer mStorageContainer;
    

    To Save:

    public static void SaveGame()
    {
       // Call this static method to begin the process; SaveGameDevice is another method in your class
       StorageDevice.BeginShowSelector(SaveGameDevice, null);
    }
    
    // this will be called by XNA sometime after your call to BeginShowSelector
    // SaveGameContainer is another method in your class
    private static void SaveGameDevice(IAsyncResult pAsyncResult)
    {       
       mStorageDevice = StorageDevice.EndShowSelector(pAsyncResult);
       mStorageDevice.BeginOpenContainer("Save1", SaveGameContainer, null);
    }
    
    // this method does the actual saving
    private static void SaveGameContainer(IAsyncResult pAsyncResult)
    {
       mStorageContainer = mStorageDevice.EndOpenContainer(pAsyncResult);
    
       if (mStorageContainer.FileExists("save.dat"))
          mStorageContainer.DeleteFile("save.dat");
    
       // in my case, I have a BinaryWriter wrapper that I use to perform the save
       BinaryWriter writer = new BinaryWriter(new System.IO.BinaryWriter(mStorageContainer.CreateFile("save.dat")));
    
       // I save the gamestate by passing the BinaryWriter
       GameProgram.GameState.SaveBinary(writer);
    
       // then I close the writer
       writer.Close();     
    
       // clean up
       mStorageContainer.Dispose();
       mStorageContainer = null;
    }
    

    Loading is very similar:

    public static void LoadGame()
    {
        StorageDevice.BeginShowSelector(LoadGameDevice, null);
    }
    
    private static void LoadGameDevice(IAsyncResult pAsyncResult)
    {
       mStorageDevice = StorageDevice.EndShowSelector(pAsyncResult);
       mStorageDevice.BeginOpenContainer("Save1", LoadGameContainer, null);
    }
    
    private static void LoadGameContainer(IAsyncResult pAsyncResult)
    {
       mStorageContainer = mStorageDevice.EndOpenContainer(pAsyncResult))
    
       // this is my wrapper of BinaryReader which I use to perform the load
       BinaryReader reader = null;
    
       // the file may not exist
       if (mStorageContainer.FileExists("save.dat"))
       {
          reader = new BinaryReader(new System.IO.BinaryReader(mStorageContainer.OpenFile("save.dat", FileMode.Open)));
    
          // pass the BinaryReader to read the data
          GameProgram.LoadGameState(reader);
          reader.Close();
       }
    
       // clean up
       mStorageContainer.Dispose();
       mStorageContainer = null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.