Delete an isolated storage file

10,223

Solution 1

Simply call IsolatedStorageFile.DeleteFile.

For example:

IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
storage.DeleteFile("backup.bak");

Solution 2

Use IsolatedStorageFile.DeleteFile.

using(var store = IsolatedStorageFile.GetUserStoreForApplication())
    store.DeleteFile("path.txt");

Solution 3

// 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

Share:
10,223
Jamie
Author by

Jamie

Updated on July 07, 2022

Comments

  • Jamie
    Jamie almost 2 years

    I know this may sound extremely nooby, so 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!

  • Jamie
    Jamie over 13 years
    Thanks, i tried it and its working but its throwing exceptions: System.ArgumentException' occurred in mscorlib.dll System.IO.IsolatedStorage.IsolatedStorageException
  • Nigel Sampson
    Nigel Sampson over 13 years
    One thing to remember is that the WP7 emulator throws out Isolated Storage when it's closed. So if you've created the file, closed the emulator and try to delete on next run you'll catch an exception.