How to determine the location of the IsolStorageFile root directory

I use IsolatedStorage for persistent objects, but from time to time I need to manually clean files from this directory. When I save the files, I want to write the physical location of the directory on the console. There seems to be no property available that returns this information. 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>>);
}
+3
source share
2 answers

Well, I did not try this, but found a link (it was not 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

:

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

, - , .

, stackoverflow: IsolStorage ?

+3

:

using System.IO.IsolatedStorage;
using System.Reflection;

var store = IsolatedStorageFile.GetMachineStoreForAssembly();
var pathName = store.GetType().GetField("m_RootDir", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(store).ToString();
+1

Source: https://habr.com/ru/post/1758302/


All Articles