1

I'm using an pictue, first load the picture to a image control in xaml:

<Image Name="pic" Height="550" Width="400"  Source="{Binding img}"  Stretch="Fill"/>

After loading to image, i want delete the source file, and also delete from teh image control.

Button click:

pic.Source = null;   
StorageFile sf = null;
StorageFolder sd = ApplicationData.Current.LocalFolder;
sf = await sd.GetItemAsync("imgs\\img") as StorageFile;
await sf.DeleteAsync();

But :Access Denied.

I use this:

pic.Source = null;

but same problem. How can i delete the image ?

Thans for all reply!

4

1 回答 1

2

解决方法是:这种格式是不可能的,但这解决了这个问题:

RandomAccessStreamReference rs= RandomAccessStreamReference.CreateFromUri(new Uri(path));
        BitmapImage bi = new BitmapImage();
        var rstream = await rs.OpenReadAsync();
        bitmapImage.SetSource(rstream);
        pic.Source = bi;

图像必须加载到流中,并且在文件可以被删除之后。

于 2013-07-13T19:53:50.473 回答