Frage

I am able to save it in isolated storage and retrieve it. But how to delete?

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));
    }

Keine korrekte Lösung

Andere Tipps

If you are using the Windows Phone Toolkit context menu, you should be able to get the data you need from the sender object, e.g.

var selected = sender as MenuItem;

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

Pass the file path to the DeleteFile method to delete a file. You should really check if the file exists first and dispose of the isoFile object when finished with it:

using (var isofile = IsolatedStorageFile.GetUserStoreForApplication())
 {
     if (isofile.FileExists("foo.txt"))
     {
          isofile.DeleteFile("foo.txt");
     }
 }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top