2
我有一个需要存储和检索孤立存储file.I数据将从Winforms应用程序的文件中存储数据,但我需要从ASP.NET应用程序中的文件检索该数据。我已成功地将数据保存在隔离文件通过这里的WinForms应用是如何在独立存储文件中存储和检索数据?
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();
}
在ASP.NET应用我会从分离的存储文件。该代码检索数据如下所示 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;
但我无法检索存储在独立存储文件从ASP.NET应用程序的数据(字符串[]的文件名= isoStore.GetFileNames(文件名);此字符串[]返回0),其指示无文件存在于机器中。
任何人都可以帮我解决这个问题吗?
是的,你是对的,两者都是不同的项目,那么我怎样才能从ASP.NET应用程序中的独立存储文件中检索数据? – Ramalingam
@Ramalingam:正如fix_likes_coding所述,isolationstorage是孤立的,因此您不能从不同的应用程序访问它。 – Fischermaen
@Fischermaen:好的,谢谢你的回复。 – Ramalingam