事实上,当你使用模拟器,你可以使用isolatedStorage,但如果你退出仿真器时,isolatedStorage被删除。
所以,你所要做的,是无法退出模拟器,让在IsolatedStorage文件,但你可以退出应用程序。
如何从内容写一个txt文件isolatedStorage
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
Stream yourFilepath = Application.GetResourceStream(new Uri("YourFilePath.txt", UriKind.Relative)).Stream;
StreamReader reader = new StreamReader(yourFilepath);
Stream yourIsolatedPath = new IsolatedStorageFileStream("YourFileIsolatedPath.txt", FileMode.CreateNew, myIsolatedStorage);
StreamWriter writer = new StreamWriter(yourIsolatedPath);
while (!reader.EndOfStream)
{
writer.WriteLine(reader.ReadLine());
}
此代码必须被放置在功能
private void Application_Launching(object sender, LaunchingEventArgs e)
{
}
在App.xaml.cs
这不是我在问什么。 从程序中创建文本文件是不可行的。我想在运行应用程序时将文件自动复制到IsolatedStorage中。 – nikhil 2012-03-16 14:34:38
我刚才纠正答案:) – Mentezza 2012-03-16 14:58:18
谢谢,这是我想要的。我会马上尝试。 – nikhil 2012-03-16 15:13:08