如何存储和检索的独立存储文件数据?独立、文件、数据

2023-09-06 05:23:16 作者:心有猛虎,

我有店面的要求和检索独立存储file.I数据将存储的数据从WinForms应用程序文件中,但我需要从文件检索ASP.NET application.I该数据已成功保存了数据隔离通过这里的WinForms应用程序文件是code

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();
            }

在ASP.NET应用程序中,我会从独立存储锉的code检索如下所示的数据                 IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForDomain();

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;

不过,我不能取回这是从ASP.NET应用程序存储在独立存储文件中的数据(字符串[]文件名= isoStore.GetFileNames(文件名);此字符串[]返回0),这表示没有文件存在于机。

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 ?

推荐答案

的独立存储被隔离(如名字已经说)。所以,你不会是能够从不同大会的访问独立存储。我假设你的ASP.NET应用程序是不是在同一个组件,您的winform应用程序

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