0
我有以下代碼在圖像控件中顯示圖像。刪除在Windows Phone圖像控件中顯示的圖像
var stream = isolatedStorage.OpenFile(imageName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(stream);
imageControl.Source = bitmapImage;
我也想給用戶選項刪除圖像。我有以下代碼。
myImage.Source = null;
isolatedStorage.DeleteFile(imageName);
但是這會導致IsolatedStorageException和消息'無法刪除文件'。
我無法使用位圖的流源屬性或使用緩存選項,因爲Windows手機不支持它們。
任何其他解決方法?
你的 第一個解決方案有效第二個解決方案不起作用。它的類型IsolatedStorageFile只能通過IsolatedStorageFile.GetUserStoreForApplication()獲得。 – Curious