コード例 #1
0
        protected virtual void ReadFromIsolatedStorage(string fileName)
        {
            using (System.IO.IsolatedStorage.IsolatedStorageFile l_Storage = GetStorage())
            {
                System.IO.IsolatedStorage.IsolatedStorageFileStream l_File = null;
                try
                {
                    l_File = new System.IO.IsolatedStorage.IsolatedStorageFileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, l_Storage);
                }
                catch (System.IO.FileNotFoundException)
                {
                    l_File = null;
                }

                if (l_File == null)                 //file non esiste
                {
                }
                else                 //file esiste
                {
                    try
                    {
                        ReadFromStream(l_File);
                    }
                    finally
                    {
                        l_File.Close();
                    }
                }

                l_Storage.Close();
            }
        }
コード例 #2
0
 protected virtual void RemoveIsolatedStorage(string fileName)
 {
     using (System.IO.IsolatedStorage.IsolatedStorageFile l_Storage = GetStorage())
     {
         l_Storage.DeleteFile(fileName);
         l_Storage.Close();
     }
 }
コード例 #3
0
        protected virtual void WriteToIsolatedStorage(string fileName, PersistenceFlags flags)
        {
            using (System.IO.IsolatedStorage.IsolatedStorageFile l_Storage = GetStorage())
            {
                System.IO.IsolatedStorage.IsolatedStorageFileStream l_File = null;
                l_File = new System.IO.IsolatedStorage.IsolatedStorageFileStream(fileName, System.IO.FileMode.Create, System.IO.FileAccess.Write, l_Storage);
                try
                {
                    WriteToStream(l_File, flags);
                }
                finally
                {
                    l_File.Close();
                }

                l_Storage.Close();
            }
        }
コード例 #4
0
        protected virtual bool IsolatedStorageExists(string fileName)
        {
            fileName = System.IO.Path.GetFileName(fileName).ToLower();
            using (System.IO.IsolatedStorage.IsolatedStorageFile l_Storage = GetStorage())
            {
                string[] files = l_Storage.GetFileNames("*");
                for (int i = 0; i < files.Length; i++)
                {
                    string fileFinded = System.IO.Path.GetFileName(files[i]).ToLower();
                    if (fileFinded == fileName)
                    {
                        return(true);
                    }
                }

                l_Storage.Close();
            }

            return(false);
        }