none
Silverlight FAQ: Kapan dan bagaimana menggunakan Isolate Storage? RRS feed

  • Diskusi Umum

  • Berikut adalah lima skenario paling umum untuk menggunakan Isolate Storage:
    1. Download control

    2. Web application storage

    3. Shared component storage

     4. Server Storage

     5. Roaming user profiles

     

    Adapun skenario yang tidak disarankan untuk menggunakan Isolate Storage:
    1. Menyimpan konten sensitif, seperti key atau password tidak terenkripsi
    2. Menyimpan kode

    3. Menyimpan konfigurasi dan pengaturan deployment 

     

    Lihat contoh sampel di bawah ini

     

    private void SaveData(string data, string fileName)

     

    {

                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())

                {

                    using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Create, isf))

                    {

                        using (StreamWriter sw = new StreamWriter(isfs))

                        {

                            sw.Write(data); sw.Close();

                        }

                    }

                }

            }        

           

            private string LoadData(string fileName)

            {

                string data = String.Empty;

                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())

                {

                    using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Open, isf))

                    {

                        using (StreamReader sr = new StreamReader(isfs))

                        {

                            string lineOfData = String.Empty;

                            while ((lineOfData = sr.ReadLine()) != null) data += lineOfData;

                        }

                    }

                }

                return data;

            }

    Link terkait

    http://msdn.microsoft.com/en-us/library/3ak841sy(VS.80).aspx

    http://msdn.microsoft.com/en-us/library/kbcw921f(VS.80).aspx

     


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Senin, 13 Juni 2011 06.17
    Moderator