I'm saving some stuff in an IsolatedStorageFile. It works well and I can retrieve the saved values when calling the saving and retrieving methods in my DAL layer from my GUI layer. However, when I try to retrieve the same settings from another assembly in the same project, it gives me a FileNotFoundException. What do I do wrong? This is the general concept:
public void Save(int number)
{
IsolatedStorageFile storage = IsolatedStorageFile.GetMachineStoreForAssembly();
IsolatedStorageFileStream fileStream =
new IsolatedStorageFileStream(filename, FileMode.OpenOrCreate, storage);
StreamWriter writer = new StreamWriter(fileStream);
writer.WriteLine(number);
writer.Close();
}
public int Retrieve()
{
IsolatedStorageFile storage = IsolatedStorageFile.GetMachineStoreForAssembly();
IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(filename, FileMode.Open, storage);
StreamReader reader = new StreamReader(fileStream);
int number;
try
{
string line = reader.ReadLine();
number = int.Parse(line);
}
finally
{
reader.Close();
}
return number;
}
I've tried using all the GetMachineStoreFor* scopes.
EDIT: Since I need several assemblies to access the files, it doesn't seem possible to do with isolated storage, unless it's a ClickOnce app.