Wednesday, 30 April 2008

Isolated Storage (used.dat)

Following on from my previous article where is showed you where the isolated storage quota for an application is stored, I will now explore the used.dat file (please read my previous article for this to make sense.

The used.dat file lives in the same directory as quota.dat. The used.dat file holds in hex the number of bytes that your application uses in Isolated Storage. If you open the file in Visual Studio and mess with the hex value, it will change what Silverlight thinks your application is using in Isolated Storage. In fact the call AvailableFreeSpace call of the userStore simply returns the quota.dat hex value (previous article) - the used.dat hex file.

This means everytime you create a file in Isolated Storage, Silverlight simply add the size of the file to the hex value in used.dat. If you delete a file it will decrease the value.

Now there is a problem with this. If i manually go into my isolated storage area in Windows, and delete a folder or a file. The used.dat value doesn't get incremented. The file/directory will however be available to the application.

This means effectively the used.dat can increase, or remove the amount of isolated storage available to your application by adding via silverlight and deleting via windows (or vice versa). Due to the way this has been implemented your available isolated storage will get into a tiz.

The good news is that you shouldn't be messing with files in your isolated storage area, so this shouldn't be an issue (in normal usage).

I will create a screencast on this (when i sort out my silverlight streaming issues)

Last night in Cambridge

Big thanks to Guy Smith-Ferrier for presenting his ADO.NET Data Services session, and Ben Hall for his windows clippy thingy nugget.

I really enjoyed the session, and I am sure everyone else did too.

The coolest thing that i learned is that ADO.NET Data Services is not just about database but works against LINQ provider (amazon, sharepoint, business objects)

Tuesday, 29 April 2008

Isolated Storage (Quota.dat)

In my previous article i discovered that Isolated Storage directories are worth 1Kb

As a follow onto this, i look into where your Isolated Storage quota is stored (there will be a screencast on this also, once i suss out my silverlight streaming issues).

So the first point of call is where is my Isolated Storage held on disk (XP: C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Silverlight\is), (Vista: C:\users\ch3\appdata\locallow\Microsoft\Silverlight\is).

If we drill down that folder, we have a g folder, and an s folder. Beneath the S folder lies a folder for each isolated storage area (for each web application). Once you workout which folder relates to which application, there is a file called group.dat, which if you open up in notepad tells you a folder name in the g (group) folder.

So if we open that group folder we will see 4 files:


Now for the more astute readers. quota.dat is what holds your allocated isolated storage.

If we open quota.dat in Visual studio, we will see some Hex:

00 00 A0 00 00 00 00 00 00 00

Now my isolated storage quota for this application is 10Mb

A00000 in Hex is 10485760. If we divide 10485760 by 1048576 (1Mb (1024 bytes (1Kb) * (1024 bytes (1Kb)), we get a value of 10, i.e. 10Mb.

This is our isolated storage quota for this application.

This means when you call the method TryIncreaseQuotaTo(someValueInBytes) of the IsolatedStorageFile (and the user gives permission to increase the quota). Silverlight will modify the Hex value in this quota.dat file.

This means if you ever need to reduce the Isolated storage quota (there is no reduce method, see my article).

This now gives you to options:

1) Nuke the group (g) and storage (s) folders for the application :)

2) Modify the limit using visual studio :)

Anyways I hope this gives you a better understanding of how the Isolated Storage quota works internally.

In my next post, I will examine the used.dat file

Monday, 28 April 2008

Silverlight Streaming (aaaaarggggggggh)

For whatever reason. I cannot get my screencast up onto Silverlight Streaming.

I keep getting failed to proccess video.

I have tried encoding the video (with various settings), and used both Expression Encoder 1.0 and the Encoder 2.0 Beta.

Same error and an unhelpful error it is. It encodes fine on my machine. I upload it to silverlight streaming. Once its uploaded it tries to process the video, and gives me the vague and generic error (failed to process video), with no clues to what is wrong.


ADO.NET Data Services

Just a quick reminder that NxtGenUG Cambridge (which myself and Allister run), have Guy Smith-Ferrier doing a talk on ADO.NET Data Services tomorrow night at Microsoft Research in Cambridge. We also have a nugget from Ben Hall.

I have to say I am look forward to this one in particular as Guy is a brilliant speaker and technologies such as ADO.NET Data Services which promote cloud computing is definately the way things are moving.

Anyways come along, and I hope to see you there

Monday, 21 April 2008

Isolated Storage Directories are worth 1Kb

It turns out Isolated Storage folders are worth 1Kb.

This is easy to test, as all you need to do is create a directory in Silverlight, and watch your available isolated storage space, reduce by 1Kb (1024 bytes).

This is all very nice, but in Windows a directory is free (i.e. if you right click on properties of a folder, it takes up zero bytes). The interesting thing, is that if you add a windows folder manually to your isolated storage directory, Silverlight will read your new directory, however it will not take up any space in isolated storage.

This means that the 1Kb of directory space is clearly a Silverlight / Isolated storage thing, not a windows thing. Therefore the AvailableFreeSpace calculation is happening idependently of the underlying file system.

So why would you want to cost a directory at 1Kb, whilst windows costs that very same directory at zero bytes? Well one reason it is that I guess is to stop nasty applications trashing your hard disk with a silverlight application that creates lots of directories (with a default of 100Kb of isolated storage and 1Kb per directory), the nasty application could only create 100 folders.

I have done a screencast on this, which I will upload in the next few days.

Silverlight 2 reducing Isolated Storage Quota

Now that I am back from holiday, it is time to blog a little.

I've been messing around with Isolated Storage for the past few days, and there is some interesting issues.

It seems to me i can increase the Isolated Storage quota (the amount of allocated isolated storage), but I don't seem to have anyway to reduce it (in the beta)?

The following code will ask the user permission to increase the quota to 1Mb (default starting quota is 100Kb)

using (IsolatedStorageFile userStore =

which is all lovely and stuff, but I have no way to reduce the quota size in the future. The only way to mess with the quota is to use TryIncreaseQuotaTo, however if you attempt set the quota to a value less than your current quota, it throws an exception.

I also tried killing my isolated storage (to no avail):

using (IsolatedStorageFile userStore =

I think it would be better if an exception was thrown if you attempted to reduce the quota below the used space (userStore.Quota - userStore.AvailableFreeSpace)