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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:00:23+00:00 2026-06-06T09:00:23+00:00

My code looks like below: private void LayoutRoot_Loaded(object sender, System.Windows.RoutedEventArgs e) { // TODO:

  • 0

My code looks like below:

private void LayoutRoot_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
        // TODO: Add event handler implementation here.
        try
        {
            string fileName = NavigationContext.QueryString["id"];
            DataSaver<SampleData> mypersonaldata = new DataSaver<SampleData>();
            var PersonData = mypersonaldata.LoadMyData(fileName);

            txtName.Text = PersonData.Name;
            txtAge.Text = PersonData.Age;
            txtheight.Text = PersonData.Height;
            txtMammals.Text = PersonData.FavMammals;
            txtBirds.Text = PersonData.FavBirds;
            txtReptiles.Text = PersonData.FavReptiles;
        }
        catch
        {
            MessageBox.Show("Unable to read!");
        }
    }

Here is my code for loading data:

public MyDataType LoadMyData(string sourceName)
{
    MyDataType retVal = default(MyDataType);
    string TargetFileName = String.Format("{0}/{1}.dat", TargetFolderName, sourceName);
    if (IsoFile.FileExists(TargetFileName))
        using (var sourceStream = IsoFile.OpenFile(TargetFileName, FileMode.Open))
        {
            retVal = (MyDataType)_mySerializer.ReadObject(sourceStream);
        }
    return retVal;
}

I am able to access the member of the DataSaver.cs and SampleData.cs. I am getting the correct filename also but unable to read the data. Please help!

    public void SaveMyData(MyDataType sourceData) 
    { 
        string TargetFileName = String.Format("{0}/{1}.dat", TargetFolderName, targetFileName); 

        if (!IsoFile.DirectoryExists(TargetFolderName)) 
            IsoFile.CreateDirectory(TargetFolderName); 

        try 
        { 
            using (var targetFile = IsoFile.CreateFile(TargetFileName)) 
            { 
                _mySerializer.WriteObject(targetFile, sourceData); 
            } 
        } 
        catch (Exception e)
        {
            IsoFile.DeleteFile(TargetFileName); 
        }
    }    

The above code is for saving data into Isolated Storage.

  • 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-06T09:00:24+00:00Added an answer on June 6, 2026 at 9:00 am

    These two static methods should help you in any read/write operation from/to WP Isolated Storage.

    public static void WriteStreamToFile(MemoryStream stream, string baseFileName, string extension, out string realFileName)
        {
            realFileName = String.Empty;
    
            if (stream != null)
                using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    baseFileName = GlobalSettings.NormalizeFileName(baseFileName);
    
                    realFileName = String.Concat(baseFileName, extension);
    
                    using (IsolatedStorageFileStream fileStream = appStorage.OpenFile(realFileName, FileMode.Create, FileAccess.Write))
                        stream.WriteTo(fileStream);
    
                }
        }
    
        public static void ReadStreamFromFile(MemoryStream stream, string fileName)
        {
            if (stream != null)
                using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
                using (IsolatedStorageFileStream fileStream = appStorage.OpenFile(fileName, FileMode.Open, FileAccess.Read))
                    fileStream.CopyTo(stream);
        }
    

    And then, you can serialize everything you want:

    public static object DeserializeObject(string fileName, Type objectType)
        {
            using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
            using (IsolatedStorageFileStream fileStream = appStorage.OpenFile(fileName, FileMode.Open, FileAccess.Read))
            using (TextReader xmlReader = new StreamReader(fileStream))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(objectType);
    
                return xmlSerializer.Deserialize(xmlReader);
            }
        }
    
        public static void SerializeObject(string fileName, object target, Type objectType)
        {
            using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
            using (IsolatedStorageFileStream fileStream = appStorage.OpenFile(fileName, FileMode.Create, FileAccess.Write))
            using (TextWriter xmlWriter = new StreamWriter(fileStream))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(objectType);
    
                xmlSerializer.Serialize(xmlWriter, target);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string containing a short-code which looks like the one below: some
I have code that looks more or less like the code below but it
I have a data that looks like this . And my code below simply
As mentioned below I have made changes to the code which looks like following
I have some code that looks like the below. Does this create a deadlock?
The spring JDBC template returns me a list which looks like below: [{CODE_C=CSC, DESC_C=CSC},
Look the code below. I'd like to replace USERNAME by the field name received
Code looks like that #include <cstdlib> #include <iostream> using namespace std; #define n 3;
My code looks like <html> <head> <title>My HTML application</title> <HTA:APPLICATION id=frames border=thin caption=yes icon=http://www.google.com/favicon.ico
My code looks like follows var html = $(el).html().toString(); html = '2012-05-10'; var re

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.