2012-11-13 61 views
0

我正在使用visual studio 2012 Ultimate在C#中編寫Windows 8應用程序。Windows 8應用程序FileNotFound異常

當試圖加載存儲在資產文件夾中的圖像資源時,我總是得到異常FileNotFoundException「系統找不到指定的文件(異常來自HRESULT:0x80070002)」,即使該文件存在於/項目的資產文件夾。

private async void LoadImage(string ImageFile) 
    { 
     Uri imageUri = new Uri("ms-appx:///Assets/Apple.jpg"); 

     StorageFile pictureFile = await StorageFile.GetFileFromApplicationUriAsync(imageUri); 

     BitmapImage bitmap = new BitmapImage(); 

     bitmap.SetSource(await pictureFile.OpenAsync(FileAccessMode.Read)); 

     imgPicture.Source = bitmap; 
    } 

任何人都可以看到什麼是錯的?

謝謝。

回答

1

沒關係,我找到了解決方案。看來您只能訪問已添加到項目中的文件。然而這是有道理的。

+0

您能否提供解決方案?它仍然不適合我:(我正在嘗試訪問僅在我的項目中的文件 – Darshan

相關問題