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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:43:52+00:00 2026-06-16T00:43:52+00:00

It doesn’t throw this error everytime, thats what makes it strange. I got 50%

  • 0

It doesn’t throw this error everytime, thats what makes it strange.
I got 50% chance that it works.

This is how I call the save method

private async void btnSave_Click(object sender, RoutedEventArgs e)
{
    await settings.WriteSettings(settings);
}

And this is the method itself

public async Task WriteSettings(Settings settings)
{
    var ser = new System.Xml.Serialization.XmlSerializer(typeof(Settings));
    var writer = new StringWriter();
    ser.Serialize(writer, settings);
    dom.LoadXml(writer.ToString());
    StorageFolder sf = ApplicationData.Current.LocalFolder;
    StorageFile st;
    st = await sf.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting); // here i get the error
    await dom.SaveToFileAsync(st);
}

I hope you guys understand the problem and you can help me getting a solution

  • 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-16T00:43:53+00:00Added an answer on June 16, 2026 at 12:43 am

    I got the reason why i get Acces denied when i try to Acces a file more than once.
    It’s because i didn’t close the file after using it.

    This is how i acces files now:

    public static async Task WriteSettings(Settings settings)
        {
            StorageFile file = await ApplicationData.Current.RoamingFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
            var stream = await file.OpenStreamForWriteAsync();
    
            var ser = new XmlSerializer(typeof(Settings));
            ser.Serialize(stream, settings);
    
            await stream.FlushAsync(); // This
            stream.Dispose(); // And this helped me solve my problem
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This doesn't work. I've got an exception from SQL databse that column does not
This doesn't compile and gives the following error: Illegal start of expression . Why?
Doesn't matter what I do, I simply can't get this to play a sound
Why doesn't this piece of code result in y == 0x100 ? uint8_t x
It doesn't look like there's a way to do this in jQuery, but I
Migration doesn't create table. Migration works great, no errors. $rake db:migrate == CreateEvents: migrating
It doesn't appear that the Source property for the XAML WebView control is updating
Why doesn't this work? I have bypassed this before but i can't remember how
I've got a string that has curly quotes in it. I'd like to replace
It doesn't look like it has that attribute, but it'd be really useful to

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.