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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:14:38+00:00 2026-05-28T11:14:38+00:00

I create a file in isolated storage and then the same file is accessed

  • 0

I create a file in isolated storage and then the same file is accessed and be edited on the click of button. But sometime an Exception occured with detail that operation is not allowed on isolated storage. This exception has no fixed time sometimes occured on first click of button some times it occuered after 5th or 6th click etc. ISOFileProcess(String module, String operation, String xmlObj) function in the below code is called on click of button.

public static void ISOFileProcess(String module, String operation, String xmlObj)
    {

        var  store = IsolatedStorageFile.GetUserStoreForApplication();

        if (store.FileExists(IsolatedMemFileHandlingCon.fileName) == false)
        {
            StreamWriter sw = new StreamWriter(store.OpenFile(IsolatedMemFileHandlingCon.fileName, FileMode.OpenOrCreate));
            CreateXML(sw,module,operation,xmlObj);

            sw.Close();
            MessageBox.Show("File Created.");
        }
        else
        {

            //store.OpenFile(IsolatedMemFileHandlingCon.fileName, FileMode.Append);

            IsolatedStorageFileStream isoStream =
                    new IsolatedStorageFileStream(IsolatedMemFileHandlingCon.fileName, FileMode.Append, FileAccess.ReadWrite, store);


            EditXML(isoStream, module, operation, xmlObj);

            isoStream.Close();


        }
    } 

    #endregion

    #region XML Creation And Editing
    private static void CreateXML(StreamWriter sw, String mname, String operation, String xmlObj)
    {

        XmlWriter xWrt = XmlWriter.Create(sw);

        xWrt.WriteStartElement("ocs");
       // xWrt.WriteStartElement("module");

        xWrt.WriteStartElement("operation");

        xWrt.WriteAttributeString("mode", operation);
        xWrt.WriteAttributeString("mname", mname);

        xWrt.WriteRaw(xmlObj);
        xWrt.WriteEndElement();
        //xWrt.WriteEndElement();

        xWrt.WriteEndElement();

        xWrt.Close();
    }

    private static void EditXML(IsolatedStorageFileStream sw, String mname, String operation, String xmlObj)
    {
        sw.Seek(sw.Length - 6, SeekOrigin.Begin);
        XmlWriterSettings wrSettings = new XmlWriterSettings();
        wrSettings.OmitXmlDeclaration = true;


        XmlWriter xWrt = XmlWriter.Create(sw,wrSettings);


        //xWrt.WriteStartElement("module");

        xWrt.WriteStartElement("operation");
        xWrt.WriteAttributeString("mode", operation);
        xWrt.WriteAttributeString("mname", mname);

        xWrt.WriteRaw(xmlObj);

        xWrt.WriteEndElement();
        //xWrt.WriteEndElement();

        xWrt.WriteRaw("</ocs>");

        xWrt.Close();

    }
  • 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-28T11:14:39+00:00Added an answer on May 28, 2026 at 11:14 am

    You specify FileMode.Append here:

     IsolatedStorageFileStream isoStream =
         new IsolatedStorageFileStream(
             IsolatedMemFileHandlingCon.fileName,
             FileMode.Append,
             FileAccess.ReadWrite, store);
    

    Append does not combine with FileAccess.ReadWrite and with moving the cursor before the end of the file.

    In the code you use random access, moving the cursor back:

     sw.Seek(sw.Length - 6, SeekOrigin.Begin);
    

    From the MSDN:

    Append Opens the file if it exists and seeks to the end of the file,
    or creates a new file. FileMode.Append can only be used in conjunction
    with FileAccess.Write. Attempting to seek to a position before the end
    of the file will throw an IOException and any attempt to read fails
    and throws an NotSupportedException.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I create a file-like object (same duck type as File) with the
I want to create a file using C++, but I have no idea how
I need to play music file from the isolated storage. i did by this
Hi In my application i have created a text file in isolated storage and
I have created a text file in isolated storage. Now when i test it
I am saving image into isolated storage each image have a different imageFileName. But
I am trying to delete the folder created in isolated storage. But i get
I have an requirement of store and retrieve data from isolated storage file.I will
I want to create a file in external storage sdCard and write to it.I
I'm trying to save a bitmap to my isolated storage as a png file.

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.