日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Silverlight 3.0 Isolated Storage 独立存储空间

發布時間:2023/12/20 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Silverlight 3.0 Isolated Storage 独立存储空间 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

????? Silverlight支持一種類似Cookie的獨立存儲,它是基于客戶端的文件系統,每個Silverlight應用程序都被分配了自己的獨立的存儲空間.

???? 這個存儲空間在不同的操作系統下是不同的WindowsXP下 是根據賬戶來分配的.一般在

C:\Document and Setting\Administrator\Local Setting\Application data\Microsoft\Silverlight\is\

??? 我的是操作系統是win7企業版,位置在

C:\Users\Administrator\AppData\LocalLow\Microsoft\Silverlight\is\

? 了解了 Isolated Storge是干嘛的

?? 接下來來介紹下 怎么在程序中應用這個存儲空間來操作目錄和文件.

1,Isolated Storge 根據應用程序不同, 有應用程序和站點兩種類型,

? 應用程序:IsolatedStorageFile.GetUserStoreForApplication();

? 站點:IsolatedStorageFile.GetUserStoreForSite();

在操作Isolated Storge? 要引入using System.IO.IsolatedStorage;命名空間

2,下面就是一寫代碼了.大家可以復制下來看看.Go

//創建目錄
?????? public void CreateDir(string dirName)
?????? {
?????????? IsolatedStorageFile stoedFile = IsolatedStorageFile.GetUserStoreForApplication();
?????????? stoedFile.CreateDirectory(dirName);
?????? }

?????? //列目錄
?????? public void LoadDirs()
?????? {
?????????? using (IsolatedStorageFile storeFile = IsolatedStorageFile.GetUserStoreForApplication())
?????????? {
?????????????? var itemSource = storeFile.GetDirectoryNames("*");
?????????? }
?????? }

?????? //刪除目錄
?????? public void DeleteDir(string dirPath)
?????? {
?????????? using (IsolatedStorageFile stro = IsolatedStorageFile.GetUserStoreForApplication())
?????????? {
?????????????? stro.DeleteDirectory(dirPath);
?????????? }
?????? }

?????? //創建文件
?????? public void SaveFile(string savePath,string content)
?????? {
?????????? IsolatedStorageFile storeFile = IsolatedStorageFile.GetUserStoreForApplication();
?????????? IsolatedStorageFileStream sf = storeFile.CreateFile(savePath);
?????????? using (StreamWriter sw = new StreamWriter(sf))
?????????? {
?????????????? sw.WriteLine(content);
?????????? }
?????????? sf.Close();
?????? }

?????? //讀取文件
?????? public void LoadFile(string readPath)
?????? {
?????????? string content = string.Empty;
?????????? using (IsolatedStorageFile storeFile = IsolatedStorageFile.GetUserStoreForApplication())
?????????? {
?????????????? if (storeFile.FileExists(readPath))
?????????????? {
?????????????????? StreamReader sr = new StreamReader(storeFile.OpenFile(readPath,FileMode.Open,FileAccess.Read));
?????????????????? content = sr.ReadToEnd();
?????????????? }
?????????? }
?????? }
?????? //刪除文件
?????? public void DeleteFile(string path)
?????? {
?????????? using (IsolatedStorageFile storeFile = IsolatedStorageFile.GetUserStoreForApplication())
?????????? {
?????????????? storeFile.DeleteFile(path);
?????????? }
?????? }

我做了一個實例的Demo喜歡的喜歡的朋友可以下載來看看

下載地址

又一天的陽光灑滿大地...

轉載于:https://www.cnblogs.com/xiaogangqq123/archive/2010/05/19/1739151.html

總結

以上是生活随笔為你收集整理的Silverlight 3.0 Isolated Storage 独立存储空间的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。