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

  • Home
  • SEARCH
  • 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 7012999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:19:45+00:00 2026-05-27T22:19:45+00:00

I want to encrypt and decrypt the isolated storage file. The Microsoft site took

  • 0

I want to encrypt and decrypt the isolated storage file.

The Microsoft site took me here

  1. While using Isolated Storage on the emulator, it can persist only until the emulator is running.

  2. There is no way to get the physical location of the Isolated Storage.

I hope the above statements of mine are correct.

Now, I want to know how can I encrypt the Isolated Storage file ?

Taking the example provided by Microsoft, (application name is GasMileage)

here is the code

namespace CodeBadger.GasMileage.Persistence
{
    public class IsolatedStorageGateway
    {
        private const string StorageFile = "data.txt";
        private readonly XmlSerializer _serializer;

    public IsolatedStorageGateway()
    {
        _serializer = new XmlSerializer(typeof (Notebook));
    }

    public Notebook LoadNotebook()
    {
        using (var store = IsolatedStorageFile.GetUserStoreForApplication())
        {
            using (var stream = GetStorageStreamForReading(store))
            using (var reader = new StreamReader(stream))
            {
                return reader.EndOfStream 
                    ? new Notebook() 
                    : (Notebook) _serializer.Deserialize(reader);
            }
        }
    }

    public NotebookEntry LoadEntry(Guid guid)
    {
        var notebook = LoadNotebook();
        return notebook.Where(x => x.Id == guid).FirstOrDefault();
    }

    public void StoreEntry(NotebookEntry entry)
    {
        var notebook = LoadNotebook();
        AssignId(entry);
        RemoveExistingEntryFromNotebook(notebook, entry);
        Console.WriteLine(entry);
        notebook.Add(entry);
        WriteNotebookToStorage(notebook);
    }

    public void DeleteEntry(NotebookEntry entry)
    {
        var notebook = LoadNotebook();
        RemoveExistingEntryFromNotebook(notebook, entry);
        WriteNotebookToStorage(notebook);
    }

    private void WriteNotebookToStorage(Notebook notebook)
    {
        using (var store = IsolatedStorageFile.GetUserStoreForApplication())
        using (var stream = GetStorageStreamForWriting(store))
        {
            _serializer.Serialize(stream, notebook);
        }
    }

    private static void AssignId(NotebookEntry entry)
    {
        if (entry.Id == Guid.Empty) entry.Id = Guid.NewGuid();
    }

    private static void RemoveExistingEntryFromNotebook(Notebook notebook, NotebookEntry entry)
    {
        var toRemove = notebook.Where(x => x.Id == entry.Id).FirstOrDefault();
        if (toRemove == null) return;
        notebook.Remove(toRemove);
    }

    private static IsolatedStorageFileStream GetStorageStreamForWriting(IsolatedStorageFile store)
    {
        return new IsolatedStorageFileStream(StorageFile, FileMode.Create, FileAccess.Write, store);
    }

    private static IsolatedStorageFileStream GetStorageStreamForReading(IsolatedStorageFile store)
    {
        return new IsolatedStorageFileStream(StorageFile, FileMode.OpenOrCreate, FileAccess.Read, store);
    }
}

Now I want to know, How to encrypt the data.txt given in the context.

On Application load, decrypt the file and on application termination, it should encrypt.

Can someone help me on this ?

  • 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-27T22:19:46+00:00Added an answer on May 27, 2026 at 10:19 pm

    The ProtectedData class will encrypt/decrypt a byte array for storing on isolated storage. You can supply your own additional entropy, but by default:

    In Silverlight for Windows Phone, both the user and machine credentials are used to encrypt or decrypt data

    For more information, see How to: Encrypt Data in a Windows Phone Application

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

Sidebar

Related Questions

here i want to encrypt and decrypt files using AES 256 Algorithm than i
I want to create an application that can encrypt and decrypt my passwords using
I want to encrypt and decrypt 10000 bytes of a music file. I used
I want to encrypt some server data using .NET's RSACryptoServiceProvider and decrypt it when
I want to encrypt and decrypt a file containing usernames and passwords. Since this
i want to Encrypt and Decrypt data in J2ME using AES Algorithm with bouncy
I want to encrypt and decrypt a file in java, i had read this
I want to encrypt and decrypt a file in java, i had read this
How can I encrypt/decrypt with fuzzy tolerance? I want to be able to use
Can anyone give me an example for encrypt and decrypt an image using .net

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.