Open up isolated storage based on identity of user + assembly evidence in CSharp

Description

The following code shows how to open up isolated storage based on identity of user + assembly evidence.

Example


//  w ww .ja  v a 2 s .  c  o m
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

using System.IO;
using System.IO.IsolatedStorage;
using System.Security.Permissions;

[assembly: IsolatedStorageFilePermission(SecurityAction.RequestMinimum, UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByUser)]
public class MainClass{
    public static void Main()
    {
      using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForAssembly())
      {
        using (IsolatedStorageFileStream isStream = new IsolatedStorageFileStream("MyData.txt",FileMode.OpenOrCreate, store))
        {
          using (StreamWriter sw = new StreamWriter(isStream))
          {
            sw.WriteLine("This is my data.");
            sw.WriteLine("Cool, huh?");
          }
        }
      }
    }
}




















Home »
  C# Tutorial »
    IO »




File Attribute
File Security
Directory Attribute
Directory Recursive
Binary File
Text Field
Buffered IO
Create Copy Delete Move
CSV
Drive
File System Watcher
Isolated Storage
MemoryStream
Serialize
Zip