ISOLATED STORAGE - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

ISOLATED STORAGE

Description:

Windows Registry Limitations : Because the registry is globally accessible, a carelessly written install ... Isolation by user, assembly, and application domain ... – PowerPoint PPT presentation

Number of Views:53
Avg rating:3.0/5.0
Slides: 22
Provided by: santosh
Learn more at: https://www.cs.odu.edu
Category:

less

Transcript and Presenter's Notes

Title: ISOLATED STORAGE


1
ISOLATED STORAGE
  • by
  • Santosh Reddy Vuppala

2
OUTLINE
  • Introduction
  • Need for Isolated Storage
  • Levels of Isolation
  • Implementation
  • Limitations
  • Conclusion

3
Introduction
  • Many applications need to write User preferences
    and Application State to a persistent store so
    that it's available each time the application
    runs.
  • Potential Stumble blocks
  • Your code might lack permission to write to an
    arbitrary file.
  • The user may lack permission to write data to an
    arbitrary file.
  • Past Approaches .INI file, Windows Registry and
    the Config file.
  • .INI file Limitations
  • INI files had no way to represent hierarchical
    information.
  • There was no standardized and safe place to keep
    INI files.
  • INI files had a size limitation.

4
Introduction
  • Windows Registry Limitations
  • Because the registry is globally accessible, a
    carelessly written install routine or
    application can bollix up the registry data for
    other applications and render them unstable or
    unusable.
  • The registry tends to swell to a huge size
    with duplicated and unneeded information, and a
    large registry slows down the entire system.
  • It's difficult to find or edit information
    in the registry.
  • Config File Limitations
  • Is that these config files are intended for
    read-only information.

5
Need For Isolated Storage
  • Isolated storage provides a controlled and
    structured mechanism through which code can write
    data to the hard drive in a way that prevents
    access by other users and managed applications.
  • Isolated storage provides a more secure data
    storage alternative than granting code direct
    access to selected areas of the hard drive .
  • In addition, isolated storage can leverage the
    capabilities of Windows-roaming user profiles,
    ensuring that a user's data is available to them
    regardless of which machine they use.

6
(No Transcript)
7
What is a Store?
  • A store is a compartment within isolated storage
    that has an identity derived from the identity of
    the user and code that created it.
  • Before managed code can save data to isolated
    storage, it must obtain a store.
  • The use of stores means that each time code runs,
    it has access to any data that it previously
    saved to isolated storage. Because different
    applications run by the same user have different
    identities, they each obtain unique stores.

8
  • A store acts as a complete virtual file system.
    You can create and delete directories and files
    within a store, and read and write data to the
    files in the store.

9
Levels of Isolation
  • Isolation by user and assembly
  • --With user and assembly isolation, one piece
    of evidence from the assembly is used.
  • Isolation by user, assembly, and application
    domain
  • --When isolating by user, assembly, and
    application domain, isolated storage uses one
    piece, of evidence from the assembly and one from
    the application domain for the stores identity

10
Isolation by User and Assembly
  • When code obtains a store isolated by user and
    assembly, isolated storage returns a store with
    an identity based on the current user and the
    assembly that made the call to obtain the store.
  • Isolation by user and assembly enables an
    assembly used in multiple applications to share
    data across those applications.
  • Used inappropriately, isolation by user and
    assembly can cause data leaks between
    applications.

11
Isolation by User, Assembly and Application Domain
  • When code obtains a store isolated by user,
    assembly, and application domain, isolated
    storage returns a store with an identity based on
    the current user, the assembly that made the call
    to obtain the store, and the application domain
    in which the assembly is loaded .
  • Isolation by user, assembly, and application
    domain limits the ability of an assembly to share
    or leak data across multiple applications .

12
Obtaining a Store
  • Two static methods of the IsolatedStorageFile
    class provide the simplest and most common way of
    obtaining a store
  • GetUserStoreForAssembly ,
    GetUserStoreForDomain
  • // Obtain a store isolated by user and assembly
  • IsolateStorageFile iso1 IsolatedStorageFile.Get
    UserStoreForAssembly( )
  • // Obtain a store isolated by user, assembly, and
    application domain IsolateStorageFile iso2
    IsolatedStorageFile.GetUserStoreForDomain( )

13
Obtaining a Store
  • The static IsolatedStorageFile.GetStore method
    also obtains a store, but allows the caller to
    specify the scope and identity of the store to
    obtain.
  • User Assembly ? Requests a store isolated by
    user and assembly, the same as that returned by
    the GetUserStoreForAssembly method.
  • User Assembly Domain ? Requests a store
    isolated by user, assembly, and application
    domain, the same as that returned by the
    GetUserStoreForDomain method.
  • Roaming User Assembly ? Requests a roaming
    store isolated by user and assembly.
  • Roaming User Assembly Domain ? Requests a
    roaming store isolated by user, assembly, and
    application domain

14
  • // GetStore equivalent of GetUserStoreForAssembly
  • IsolatedStorageFile iso1 IsolatedStorageFile.Ge
    tStore( IsolatedStorageScope.User
    IsolatedStorageScope. Assembly, null, null )
  • // GetStore equivalent of GetUserStoreForDomain
  • IsolatedStorageFile iso2 IsolatedStorageFile.Ge
    tStore( IsolatedStorageScope.User
    IsolatedStorageScope.Assembly
    IsolatedStorageScope.Domain, null, null )
  • // Get a roaming store isolated by user and
    assembly. Specify new Url evidence for the
    assembly identity
  • IsolatedStorageFile iso3 IsolatedStorageFile.Ge
    tStore( IsolatedStorageScope.User
    IsolatedStorageScope.Assembly
    IsolatedStorageScope.Roaming, null, new
    Url(_at_"http//test.com") )

15
Creating Directories
  • The basic way of doing it
  • public void CreateDirectory( string dir )
  • To create more than one level of the directory
    hierarchy in a single call.
  • IsolatedStorageFile iso IsolatedStorageFile.GetU
    serStoreForDomain( ) iso.CreateDirectory(_at_"Dir1\D
    ir2")
  • iso.CreateDirectory("Dir1/Dir3")

16
Creating, Reading and Writing Files
  • The IsolatedStorageFileStream class represents a
    file in a store
  • public IsolatedStorageFileStream(
  • string path,
  • FileMode mode,
  • FileAccess access,
  • FileShare share,
  • int bufferSize,
  • IsolatedStorageFile isf )
  • mode represents either open or create
  • access represents either read or write
  • The isf argument is a reference to the
    IsolatedStorageFile in which to create or open
    the file.

17
Deleting Files and Directories
  • The files and directories from a store can be
    deleted through the methods of the
    IsolatedStorageFile object that represents the
    containing store.
  • Both the DeleteDirectory and DeleteFile methods
    take a single String argument that specifies the
    fully qualified name of the file to delete .
  • public void DeleteDirectory( string dir )
  • public void DeleteFile( string file )

18
Delete Stores
  • To delete a store, we use the Remove method of
    the IsolatedStorageFile class.
  • Remove has two overloads, with the signatures
    shown here
  • public override void Remove( )
  • public static void Remove(
    IsolatedStorageScope scope )
  • The scope argument can take any of these
    values
  • User ? Removes all nonroaming stores for
    the current user
  • Roaming User ? Removes all roaming stores
    for the current user

19
Limitations of Isolated Storage
  • Here are some situations when the use of isolated
    storage is inappropriate
  • When valuable or secret data is used
  • When data between users is shared
  • When managed and nonmanaged code need application
    access
  • When there is no roaming-profile support
  • When used as a primary file store
  • When large amounts of data are used

20
References
  • http//www.codeproject.com/dotnet/IsolatedStorage.
    asp
  • http//www.dotnetdevs.com/articles/IsolatedStorage
    .aspx
  • http//www.codeguru.com/csharp/csharp/cs_data/arti
    cle.php/c4225/

21
  • Questions?
Write a Comment
User Comments (0)
About PowerShow.com