views:

61

answers:

1

I'm using IsolatedStorage for persisting objects, but from time to time I need to manually clean out files from this directory. As I persist the files, I want to write the physical location of the directory to the console. There doesn't appear to be an accessible property that returns this information though. How should I do it?

Here is my incomplete code:

using (var store = IsolatedStorageFile.GetMachineStoreForAssembly())
{
   Console.WriteLine("Persisting Hotel to {0}", store.<<INSERT APPROPRIATE PROPERTY>>);
}
+1  A: 

Well, I haven't tried this, but I did find a link (wasn't easy to find) that supposedly shows how to do this: http://msmvps.com/blogs/angelhernandez/archive/2008/10/04/retrieving-file-path-from-isolatedstorage.aspx

Basically the key line of code appears to be:

fileName = isoStore.GetType.GetField("m_RootDir",Reflection.BindingFlags.NonPublic or Reflection.BindingFlags.Instance).GetValue(isoStore).ToString

I'm not sure if any special permissions have to be set to get this to work.

Ok, also found a related stackoverflow: http://stackoverflow.com/questions/1112681/can-i-get-a-path-for-a-isolatedstorage-file-and-read-it-from-external-application

Mafu Josh