Lendo arquivos no Windows Phone 8: o valor não está dentro do intervalo esperado
Eu sou realmente problemas quando arquivos abertos armazenados no meu projeto. Eu preciso abrir alguns arquivos (pdf, html, ...) e sempre tem o mesmo problema:O valor não cai dentro do esperado.
Eu tentei várias maneiras:
a)
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));
Essas ações são iniciadas quando eu pressiono um botão.
Eu não sei o que acontece.
Os arquivos estão em Solution'NewProject '/ NewProject / Assets / Data / * /