I came across a bug in my application which required me to fill the IsolatedStorageFile to reproduce. I thought I would share this snippet for any of you out there that need to quickly fill your isolated storage in your app to reproduce a full isolated storage environment.
private static void FillUpISO()
{
int loopCount = 600;
string content = "al;jd fkjasdklfj alks;djf lkajsd klfjlkdasj fklj alsdjfk jadlkjflk;ajsd;lfkj kldsjf lk;jdkljldjglkjdgk dghkd fjkl dlk;fj l;kdj sfk asd " +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj" +
"alkdjf l;asjd fk;lj dsakl;fj klajds flkjds alkfjl;ksadj fkljdlk;fj lkadsj fl;kj adslkfj lkd jflk jdlkf jkld asjkl;f jkl;adsj fkljdlksa jfl;kajsd ;lfkjaskdfj";
if (!IsolatedStorageFile.IsEnabled)
return;
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForSite())
{
using (IsolatedStorageFileStream isfs
= new IsolatedStorageFileStream("Whatever",
FileMode.OpenOrCreate,
FileAccess.ReadWrite,
isf))
{
using (StreamWriter writer = new StreamWriter(isfs))
{
writer.WriteLine(content);
writer.Close();
}
isfs.Close();
}
}
try
{
for (int i = 0; i < loopCount; i++)
{
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForSite())
{
using (IsolatedStorageFileStream isfs
= new IsolatedStorageFileStream("Whatever",
FileMode.Append,
FileAccess.Write,
isf))
{
using (StreamWriter writer = new StreamWriter(isfs))
{
writer.WriteLine(content);
writer.Close();
}
isfs.Close();
}
}
}
}
catch (IsolatedStorageException isex)
{
var i = isex.Message;
}
}
Simply add the method from my sample app, or above, to one of your classes in your application and make the call to it. Here is the sample app.
http://cid-ab80127ae39f5a1e.office.live.com/self.aspx/.Public/fillIsolatedStorageHelper.zip
Cheers,
Bryon
No comments:
Post a Comment