
Originally Posted by
Kunal Prime
Hi Loukt,
So i need to check and handle these conditions by myself using timer or some other logic right.? System will not convey me by raising some event when IsolatedStorageFile.GetUserStoreForApplication().AvailableFreeSpace becomes low.
Regards
Hello Kunal,
not necessary a timer, but each time you want to write on the IsolatedStorageFile
use this snippet to check if there is enough disk space, (I think neededSpace needs to be the byte value, as for 1Mb => 1*1024*1024 bytes )
Code:
public void CheckDiskSpace(long neededSpace)
{
using (IsolatedStorageFile myISFile = IsolatedStorageFile.GetUserStoreForApplication())
{
if (myISFile.AvailableFreeSpace > neededSpace)
{
if (!myISFile.IncreaseQuotaTo(myISFile.Quota + neededSpace)) // newSpace = oldSpace(myISFile.Quota) + neededSpace
{
throw new Exception("No space available on the phone, please delete a file");
}
}
}
}
I've just wrote it and didn't test it yet, you can run it and give us feedback.
Yassine,