Skip to content

Instantly share code, notes, and snippets.

@biac
Created December 8, 2012 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biac/4239370 to your computer and use it in GitHub Desktop.
Save biac/4239370 to your computer and use it in GitHub Desktop.
WP8 の C# から Windows Phone ランタイム コンポーネントを使う
private async void ReadFile()
{
// バイト配列に読み込んでから、MultiByteToWideChar()を通す
const string FileUrl = "ms-appx:///TextFile1.txt";
var storage = await StorageFile.GetFileFromApplicationUriAsync(new Uri(FileUrl));
using (var stream = await storage.OpenReadAsync())
{
byte[] buff = new byte[stream.Size];
await stream.AsStreamForRead().ReadAsync(buff, 0, buff.Length);
this.textBox2.Text = WindowsPhoneRuntimeComponent.MultiByteToWideCharWP8(buff);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment