Question

I am using IsolatedStorage technology in my C# .net application.

My Application saves data on close in a file called MyData.dat in the isolated storage.

when i open my application it reloads that data and print it on the screen.

when i move my application to another directory, for example from D:\MyApp.exe to D:\Apps\MyApp.exe, and then run the application from it's new directory, it fails loading the file MyData.dat (FileNotFoundException) because it looking for a different MyData.dat file in a different place..

Does somebody know how i can save my isolated file - MyData.dat file in a place that no matter from where i open my App.exe it will find it?

Was it helpful?

Solution

Check the directory of IsolatedStorage retrived in both cases. Even if the machine is the same, expected storage path could be different for the same application in different locations.

Get isolation storage path

OTHER TIPS

I think that your assembly info has changed in some way. For example, before moving your exe it was version 1.0.0.0 and in another directory you put different version 1.0.0.1. In this case there should be two separate directories in isolates storage location (see another answers) for these two different versions.

Or it is possible that first time you run your app in debug mode inside VS and then you moved your exe and run it directly. In this case there should be two different directories like yourappname and yourappname.vschost.

Anyway please inspect your isolated storage locations to get more info.

You can use IsolatedStorageFile.GetUserStoreForAssembly to get a store you can use, as long as the assmbly identity is unchanged. So it will also be independent of the location of the exe file. See the MSDN Article

I tried it myself and I noticed that the AssemblyIdentity on the IsolatedStorageFile instance changes when you move the application in another folder.

To prevent this, you have to sign the assembly and only then you can move the application into another folder and still use the same location for the isolated storeage file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top