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 8577257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:07:07+00:00 2026-06-11T20:07:07+00:00

How can I Serialize Object in windows 8 Metro App Development to xml file

  • 0

How can I Serialize Object in windows 8 Metro App Development to xml file ?
I don’t know how to create stream , when I create streamWriter I get error on the file direction

StreamWriter nsw = new StreamWriter(@”C:\sample.xml”);

Error:
The best overload method match ‘system.io.streamwriter..streamwriter(system.io.stream) has some invalid arguments

this is the main code :

 StorageFolder storageFolder = KnownFolders.DocumentsLibrary;
 StorageFile sampleFile = await storageFolder.CreateFileAsync("sample.xml");
 XmlSerializer serializer = new XmlSerializer(ob.GetType());
 serializer.Serialize(Stream stream,ob);
  • 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-06-11T20:07:09+00:00Added an answer on June 11, 2026 at 8:07 pm

    Here is an example that I use. The Serialize call (last line in your code) looks wrong.

    private async void SaveButton_Click(object sender, RoutedEventArgs e)
    {
        FileSavePicker fileSavePicker = new FileSavePicker();
        fileSavePicker.DefaultFileExtension = ".bla";
        fileSavePicker.FileTypeChoices.Add("Bla Files", new List<string> { ".bla" });
        fileSavePicker.SuggestedFileName = "New Bla File";
        fileSavePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
        var file = await fileSavePicker.PickSaveFileAsync();
        if (file != null)
        {
            using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(TypeToBeSerialized));
                serializer.Serialize(stream.AsStreamForWrite(), objectToBeSerialized);
                await stream.FlushAsync();
                stream.Size = stream.Position;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What C-sharp type can I serialize to get JSON object with format name:[[1,2,3],[1,2,3],[1,2,3]] If
I have a timer function that serialize an object into a xml file once
I can't serialize it, therefore can't get byte[]. Network whiteboard with .net is impossible?)
I am using the NetDataContractSerializer. I can create, add and serialize objects into data
I've got an XML file that is created via my Windows form to save
I'm trying to serialize an object into JSON in Silverlight on Windows Phone 7.
I'm trying to pass a complex object via Windows Communication Foundation, but I get
In my app (Windows 8 Metro) I store some objects in the local Folder
I have a message object serialized as binary data stream (it can be any
I want serialize object to binary file using operator <<, but when I serialize,

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.