Delete an isolated storage file
I know this may sound extremely nooby, s开发者_开发百科o sorry in advance but I am learning and I have spent nearly 2 hours trying to find out how to do this now with no result...
I'm wondering how I would go about deleting a specific file from isolated storage in windows phone 7.
Thanks in advance!
Simply call IsolatedStorageFile.DeleteFile
.
For example:
IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
storage.DeleteFile("backup.bak");
Use IsolatedStorageFile.DeleteFile
.
using(var store = IsolatedStorageFile.GetUserStoreForApplication())
store.DeleteFile("path.txt");
// you should add here try / catch blocks
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
store.DeleteFile("Your file Name string");
}
You can check the class here: MSDN IsolatedStorageFile Class
Just to add to the existing answers: remember to catch an IsolatedStorageException and not an IOException as you might be use to.
精彩评论