Jamie
Jamie

Reputation: 4960

Delete an isolated storage file

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!

Upvotes: 8

Views: 10488

Answers (4)

racsonp
racsonp

Reputation: 121

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

Upvotes: 2

Chris S
Chris S

Reputation: 65426

Just to add to the existing answers: remember to catch an IsolatedStorageException and not an IOException as you might be use to.

Upvotes: 0

driis
driis

Reputation: 164291

Use IsolatedStorageFile.DeleteFile.

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

Upvotes: 5

Jon Skeet
Jon Skeet

Reputation: 1500165

Simply call IsolatedStorageFile.DeleteFile.

For example:

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

Upvotes: 10

Related Questions