check with below methods, if you have setup development environment in windows 8 PC, you better debug line by line and check what is going wrong.
To write a file:
public async Task WriteFile(string fileName, string text)
{
IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
IStorageFile storageFile = await applicationFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
using (Stream stream = await storageFile.OpenStreamForWriteAsync())
{
byte[] content = Encoding.UTF8.GetBytes(text);
await stream.WriteAsync(content, 0, content.Length);
}
}
To read a file:
public async Task<string> ReadFile(string fileName)
{
string text;
IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;
IStorageFile storageFile = await applicationFolder.GetFileAsync(fileName);
IRandomAccessStream accessStream = await storageFile.OpenReadAsync();
using (Stream stream = accessStream.AsStreamForRead((int)accessStream.Size))
{
byte[] content = new byte[stream.Length];
await stream.ReadAsync(content, 0, (int) stream.Length);
text = Encoding.UTF8.GetString(content, 0, content.Length);
}
return text;
}</string>
Ref :
Windows Phone 8 Shared Core With Windows 8 – File IO[
^]