I have an requirement of store and retrieve data from isolated storage file.I will store data in the file from Winforms application but I need to retrieve that data from file in ASP.NET application.I have successfully saved the data in Isolated file through winforms application here is the code
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForDomain();
string[] fileNames = isoStore.GetFileNames(fileName);
if (fileNames != null && fileNames.Length > 0)
{
foreach (string file in fileNames)
{
if (file == fileName)
{
isSuccess = true;
break;
}
else
isSuccess = false;
}
}
if (!isSuccess)
{
oStream = new IsolatedStorageFileStream(fileName, FileMode.Create, isoStore);
writer = new StreamWriter(oStream);
writer.WriteLine(licenseCode);
writer.Close();
}
In ASP.NET application I will retrieve data from the isolated storage file.The code is shown below
IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForDomain();
string[] fileNames = isoStore.GetFileNames(fileName);
//Retrieve License Code from Isolated storage
iStream = new IsolatedStorageFileStream(fileName, FileMode.Open, isoStore);
reader = new StreamReader(iStream);
String line;
while ((line = reader.ReadLine()) != null)
{
output = line;
}
return output;
But I am unable to retrieve the data which is stored in Isolated storage file from ASP.NET application (string[] fileNames = isoStore.GetFileNames(fileName); this string[] returns 0) which indicates no file exists in the machine.
Could anyone help me to solve this issue ?
The isolated storage is isolated (as the name says already). So you wont be able to access isolated storage from different assemblys. I assume your ASP.NET app is not in the same assembly as your Winform app