Presentation is loading. Please wait.

Presentation is loading. Please wait.

by Santosh Reddy Vuppala

Similar presentations


Presentation on theme: "by Santosh Reddy Vuppala"— Presentation transcript:

1 by Santosh Reddy Vuppala
ISOLATED STORAGE by Santosh Reddy Vuppala 4/21/2019

2 OUTLINE Introduction Need for Isolated Storage Levels of Isolation
Implementation Limitations Conclusion 4/21/2019

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/21/2019

4 Introduction Windows Registry Limitations : Config File 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. 4/21/2019

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. 4/21/2019

6 4/21/2019

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. 4/21/2019

8 A store acts as a complete virtual file system
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. 4/21/2019

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 4/21/2019

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. 4/21/2019

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 . 4/21/2019

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.GetUserStoreForAssembly( ); // Obtain a store isolated by user, assembly, and application domain IsolateStorageFile iso2 = IsolatedStorageFile.GetUserStoreForDomain( ); 4/21/2019

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 4/21/2019

14 // GetStore equivalent of GetUserStoreForAssembly
IsolatedStorageFile iso1 = IsolatedStorageFile.GetStore( IsolatedStorageScope.User | IsolatedStorageScope. Assembly, null, null ); // GetStore equivalent of GetUserStoreForDomain IsolatedStorageFile iso2 = IsolatedStorageFile.GetStore( 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.GetStore( IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Roaming, null, new ); 4/21/2019

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.GetUserStoreForDomain( ); iso.CreateDirectory("Dir1/Dir3"); 4/21/2019

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. 4/21/2019

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 ); 4/21/2019

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 4/21/2019

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 4/21/2019

20 References http://www.codeproject.com/dotnet/IsolatedStorage.asp
4/21/2019

21 Questions? 4/21/2019


Download ppt "by Santosh Reddy Vuppala"

Similar presentations


Ads by Google