Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight IsolatedStorage PathTooLongException

I'm getting this exception on 50% of WinXP SP3 machines. I know about 260 characters path length limit, but what can be done?

I'm already naming files to only 2 characters, without any subdirectories, but path to IsolatedStorage is already above 260 characters on half of WinXP machines.

like image 241
Alex Burtsev Avatar asked Aug 15 '11 07:08

Alex Burtsev


1 Answers

There ´s seems to be no real solution for this problem. The default path for the Isolated Storage under Windows XP is <SYSTEMDRIVE>\Documents and Settings\\Local Settings\Application Data\Microsoft\Silverlight\is on an english system, what is already really long. On MSDN is a good article about using Isolated Storage and Best Practises.

When you use isolated storage, following these guidelines will help you avoid problems and make the most of the protection isolated storage provides.

  • Wrap all calls to isolated storage within try/catch blocks to be resilient to potential IsolatedStorageExceptions, which can be thrown if isolated storage is
    disabled or if the store has been deleted.
  • If your Silverlight application needs to store a lot of data in isolated storage, consider hosting it on its own site so that it won't affect other applications on the site and other applications won't affect it.
  • If you have a group of Silverlight applications that need to share data on the client, host them on the same site.
  • Keep isolated storage paths as small as possible to prevent the internal full path from reaching the 260-character limit.
  • Encrypt sensitive data stored in isolated storage.
  • Use IsolatedStorageSettings to store objects and simple settings in isolated storage.
  • Use IsolatedStorageFile if you want to use file and stream-based APIs, are storing large amounts of data, or need fine-grained control over the contents of isolated storage.

To get around a PathToLongException you could check first the path of the IsolatedStorage and use an internal mapping to store your files in the IsolatedStorage. If the path to IsolatedStorage is too long by itself you should consider hosting the silverlight application on it´s own site and use IsolatedStorageFile.GetUserStoreForSite.

like image 102
Jehof Avatar answered Sep 28 '22 11:09

Jehof