我在讀.NET中的System.IO.IsolatedStorage命名空間,發現我可以使用它來將文件存儲到我的程序集或可執行文件唯一的位置。例如,下列代碼:有人使用.NET的System.IO.IsolatedStorage嗎?
using System.IO.IsolatedStorage;
public class Program
{
static void Main(string[] args)
{
IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForAssembly();
store.CreateFile("myUserFile.txt");
}
}
創建文件 「myUserFile.txt」 在以下位置:
C:\用戶\尼克\應用程序數據\本地\ IsolatedStorage \ bhxcjtkp.bpv \ wbjkcolm.3br \ StrongName.m2s0saaun2onmow3pd5pkml30lf2dobr \ AssemFiles
而且使用IsolatedStorageFile.GetMachineStoreForAssembly()
在C創建一個類似的目錄結構:\ ProgramData \ IsolatedStorage。
我可以看到讓API爲您創建存儲位置的好處(不必自己考慮文件路徑)。但是我驚訝地發現,其他第三方應用程序中沒有其他文件存儲在IsolatedStorage中(至少不在我的計算機上)。
取而代之的是,我發現了很多存儲配置文件的程序,簡單地在C:\ Users \ Nick \ AppData \ Local下。有誰知道軟件供應商爲什麼不願意使用IsolatedStorage的原因?還是他們使用不同的API來存儲AppData下的文件?
我很確定很多人都在使用IS。 – BoltClock