1

我可以将它保存在独立的存储中并检索它。但是怎么删除呢?

private void Deleting(object sender, RoutedEventArgs e)
    {
        MessageBoxResult message = MessageBox.Show("The Files will be permanently deleted.","Continue?", MessageBoxButton.OKCancel);

        if (message == MessageBoxResult.OK)
        {
            IsolatedStorageFile isofile = IsolatedStorageFile.GetUserStoreForApplication();
            isofile.DeleteFile("//What to do here?");

        }

        else if (message == MessageBoxResult.Cancel)            

        NavigationService.Navigate(new Uri("/MyRecordings.xaml", UriKind.RelativeOrAbsolute));
    }
4

1 回答 1

0

如果您使用的是 Windows Phone Toolkit 上下文菜单,您应该能够从 sender 对象中获取您需要的数据,例如

var selected = sender as MenuItem;

见这里:http: //blogs.msdn.com/b/msgulfcommunity/archive/2013/05/19/windows-phone-toolkit-context-menu-getting-selected-item-within-a-long-list-selector .aspx

将文件路径传递给 DeleteFile 方法以删除文件。您应该首先检查文件是否存在,并在完成后处理 isoFile 对象:

using (var isofile = IsolatedStorageFile.GetUserStoreForApplication())
 {
     if (isofile.FileExists("foo.txt"))
     {
          isofile.DeleteFile("foo.txt");
     }
 }
于 2013-11-05T00:18:56.573 回答