Skip to main content
Home Forums Silverlight Programming Report a Silverlight Bug OpenFileDialog causes IsolatedStorageFile.IncreaseQuotaTo to fail
7 replies. Latest Post by martinording on June 26, 2009.
(0)
NinetiesGuy
Member
12 points
3 Posts
08-31-2008 10:18 PM |
Hey guys,
I'm using Silverlight 2 beta 2...
After a button click, if you show a file dialog, a call to increase the isolated storage quota will fail without showing the user dialog.
Here's the process I'm trying to get to work: When the user clicks the button, show the file dialog, calculate quota increase based on the selected files, increase quota if necessary, and store files.
If the call to IsolatedStorageFile.IncreaseQuotaTo is placed before the file dialog, it works as expected. But that isn't an option because I need to calculate the size needed based on the file dialog result.
Here's code to reproduce:
private void button_Click(object sender, RoutedEventArgs e) { using (IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()) { //this shows increase request dialog isolatedStorageFile.IncreaseQuotaTo(isolatedStorageFile.Quota * 2); OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { //this doesn't show increase dialog, returns false automatically isolatedStorageFile.IncreaseQuotaTo(isolatedStorageFile.Quota * 2); } } }
Thanks,
Chris
lilach
4 points
6 Posts
10-08-2008 4:26 AM |
Hi Chris,
we are now having the same problem, Did you get any information about this?
thanks,
Lilach
kwatts
Contributor
2129 points
436 Posts
10-08-2008 9:04 AM |
It turns out that the default limit for isolated storage is now 100 KB, which is down from 1 MB in Silverlight 1.0. This article has more details:
http://silverlightuk.blogspot.com/2008/02/isolated-storage-in-silverlight-2.html
The good news is this limit can be increased, but it's something that needs to be done on the user's end. I hope that this helps!
-Ken
10-08-2008 2:05 PM |
Lilach: No, still haven't found a solution. Our best workaround is to just pick some arbitrary large number and hope that's big enough. Annoying because I have to error-check everything I do after the dialog closes to ensure there is enough space at that moment. If it worked correctly, I could allocate enough space early in the process and not have to worry about it anymore.
kwatts: The problem isn't increasing the storage quota. The problem is increasing it after the OpenFileDialog is shown. IncreaseQuotaTo returns false without prompting the user. So if you're dealing with the file system at all, there's no way to know how much space you need.
10-08-2008 2:12 PM |
NinetiesGuy:kwatts: The problem isn't increasing the storage quota. The problem is increasing it after the OpenFileDialog is shown. IncreaseQuotaTo returns false without prompting the user. So if you're dealing with the file system at all, there's no way to know how much space you need.
My point is you're not going to be able to increase the quota beyond 100K in code. The end-user will have to do this manually. I'm guessing there are security concerns here.
10-12-2008 3:37 AM |
our problem is only that the IncreaseQuotaTo returns false without prompting the user. is there a chance that the storage quota was increased even though it didn't prompt the user?
we are asking for 200M from the user. 100K will certanly not be enough.
does anyone know the reason the window fails to open?
ahura mazda
40 points
5 Posts
10-27-2008 7:09 AM |
I'm having the same issue but with the RTW version.
Using Reflector, I see that the method IncreaseQuotaTo() internally calls a security method that always returns false, which looks like it eventually will cause IncreaseQuotaTo to fail.
Did a bit more research and the call to IncreaseQuotaTo() must be called from an event handler (it states so in the Silverlight SDK). I'm assuming that OpenFileDialog.ShowDialog() probably resets some internal checks and anycalls after to IncreaseQuotaTo() will fail silently.
Did even more look ups and found this:http://www.wilcob.com/Wilco/View.aspx?NewsID=211
martinor...
5 points
15 Posts
06-26-2009 5:00 AM |
A typical usage patter for OpenFileDialog and IncreaseQuotaTo is this:
bool save = false; OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog()) { using (IsolatedStorageFile iso = IsolatedStorageFile.GetUserStoreForApplication()) { if (iso.AvailableFreeSpace < dialog.File.Length) { save = iso.IncreaseQuotaTo(iso.Quota - iso.AvailableFreeSpace + dialog.File.Length); } else save = true; } } if (save) { // ... }
When IsolatedStorageFile.IncreaseQuotaTo gets called, it is always after a call to OpenFileDialog.ShowDialog.
You really need to allow IncreaseQuotaTo to be called after OpenFileDialog.ShowDialog. It is the only way to make Silverlight apps user friendly.