簡體   English   中英

在Windows Phone 8中寫入文件

[英]Writing files in windows phone 8

我想在Windows Phone 8應用程序中從文本文件讀取和寫入數據。 我嘗試了這段代碼

IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
StreamWriter wr = new StreamWriter(new IsolatedStorageFileStream("File.txt", FileMode.OpenOrCreate, isf));
wr.WriteLineAsync("Hello");
wr.Close();

但是它什么也沒做。 請幫我解決這個問題。 謝謝。

將數據寫入文件:

IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

//create new file
using (StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream("myFile.txt", FileMode.Create, FileAccess.Write, myIsolatedStorage)))
{
   string someTextData = "This is some text data to be saved in a new text file in the IsolatedStorage!";
   writeFile.WriteLine(someTextData);
   writeFile.Close();
}

從文件讀取數據:

IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("myFile.txt", FileMode.Open, FileAccess.Read);
using (StreamReader reader = new StreamReader(fileStream))
{    
     //Visualize the text data in a TextBlock text
     this.text.Text = reader.ReadLine();
}

瀏覽以下鏈接: http : //www.geekchamp.com/tips/all-about-wp7-isolated-storage-read-and-save-text-files

https://www.google.co.in/#q=wp8+isolated+storage+geek

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM