Developer to developer

Note for Chapter 2.4 : [Isolated Storage]

  • Seperti namanya, Isolated Storage, dalam lingkup IO, kita mempunyai hak read/write file di storage yang secure. Sehingga aplikasi kita dapat berjalan, apapun hak akses kita.
  • Class : IsolatedStorageFile (untuk mengakses store/membuat object store), IsolatedStorageFileStream (read/write store file), IsolatedStorageFilePermission (digunakan sebagai attribut/anotasi).
  • Ada 2 level akses untuk membuat objek store :
    • Assembly/Machine : Berguna untuk membuat application-level data.

Dim MachineStore As IsolatedStorageFile = _

IsolatedStorageFile.GetMachineStoreForAssembly()

  • Assembly/User : Berguna untuk membuat user-level data.

Dim UserStore As IsolatedStorageFile = _

IsolatedStorageFile.GetUserStoreForAssembly

  • Contoh. Jika read data menggunakan enum FileMode.Open. Gunakan FileMode.Create untuk write data :

‘Jika diperlukan, buat directory

store.CreateDirectory(“MyDir”)

Dim userStream As IsolatedStorageFileStream = New _

IsolatedStorageFileStream(“MyDir\UserSettings.set”, _

FileMode.Create, _

UserStore)

  • Untuk mendapatkan directory :

Dim directories() As String = _

UserStore.GetDirectoryNames(“MyDir”)

If directories.Length = 0 Then

‘Jika diperlukan, buat directory

End If

  • Mengijinkan Assembly menggunakan Isolated Storage menggunakan class IsolatedStorageFilePermission (Import Security.Permission terlebih dahulu):

<IsolatedStorageFilePermission(SecurityAction.Demand, _

UserQuota:=1024, _

UsageAllowed:= _

IsolatedStorageContainment.AssemblyIsolationByUser)> _

Class Program

‘ …

End Class

Standard

One thought on “Note for Chapter 2.4 : [Isolated Storage]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s