0
當打開存儲在我的項目中的文件時,我真的很擔心。我需要打開一些文件(pdf,html,...),並且有同樣的問題:價值不符合預期範圍。在Windows Phone 8中讀取文件:值不在預期範圍內
我已經嘗試了幾種方法:
一)
private async Task<string> ReadFileContentsAsync(string fileName)
{
StorageFolder foldera = ApplicationData.Current.LocalFolder;
try
{
Stream filea = await foldera.OpenStreamForReadAsync("/Assets/Data/htm/" + fileName + ".htm");
...
}
catch (Exception e)
{
Debug.WriteLine("ERROR ReadFileContentsAsync " + e.Message);
return null;
}
}
B)
private async Task<string> ReadFileContentsAsync(string fileName)
{
try
{
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(
new Uri("ms-appdata:///Assets/Data/htm/" + fileName + ".htm", UriKind.RelativeOrAbsolute));
...
}
catch (Exception e)
{
Debug.WriteLine("ERROR ReadFileContentsAsync " + e.Message);
return null;
}
}
C)
StorageFile file2 = await StorageFile.GetFileFromApplicationUriAsync(
new Uri("ms-appdata:///Assets/Data/pdf/lc_dossier_acceso_castellana.pdf", UriKind.Absolute));
當我按下一個按鈕,這個動作被推出。
我不知道發生了什麼事。
的文件是在Solution'NewProject'/ NewProject /資產/數據/ */
感謝, 「VAR FILESTREAM = File.OpenRead(」 資產/數據/ HTM/「+文件名+名」 htm 「);」作品!! –