Windows Phone 7 Isolated Storage Helper
While working with isolated storage on WP7, I faced a lot of problems such as deleting a folder containing files. The default behavior of the isolated storage is safe, this means it will not delete folders that contains files. I was also missing the convenience methods ReadAllLines() and WriteAllLines() we normally have in the .NET Framework 4.
I decided to write a small helper that supports this functionality. You can find a description of each below:
DeleteDirectoryRecursive()
WP7 isolated storage does not delete folders that contains files. This method finds all sub folders, delete files inside the sub folders and then the folder itself.
ReadAllLines()
Reads all the lines of a file and puts them into a list. This is missing from the IsolatedStorageFile API
WriteAllLines()
Writes all the lines of an enumerable collection to a file. If the file does not exist, it will create it. If the file already exists, it will overwrite the file. Just as ReadAllLines(), it is just a convenience method that is missing from the IsolatedStorageFile API.
The code can be found on my SkyDrive.
I decided to write a small helper that supports this functionality. You can find a description of each below:
DeleteDirectoryRecursive()
WP7 isolated storage does not delete folders that contains files. This method finds all sub folders, delete files inside the sub folders and then the folder itself.
ReadAllLines()
Reads all the lines of a file and puts them into a list. This is missing from the IsolatedStorageFile API
WriteAllLines()
Writes all the lines of an enumerable collection to a file. If the file does not exist, it will create it. If the file already exists, it will overwrite the file. Just as ReadAllLines(), it is just a convenience method that is missing from the IsolatedStorageFile API.
The code can be found on my SkyDrive.
Comments
Post a Comment