Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PCLStorage文件系统仅在Android中可用,不在iOS中可用_C#_Ios_Xamarin_Xamarin.ios_Xamarin.android - Fatal编程技术网

C# PCLStorage文件系统仅在Android中可用,不在iOS中可用

C# PCLStorage文件系统仅在Android中可用,不在iOS中可用,c#,ios,xamarin,xamarin.ios,xamarin.android,C#,Ios,Xamarin,Xamarin.ios,Xamarin.android,我正在用xamarin为Android和iOS编写一个跨平台应用程序,我需要将一些文本文件保存到本地存储。我使用的是PCLstorage,但每当我将鼠标移到任何PCLstorage代码上时,它都会显示“MyApplication.Android:可用,MyApplication.iOS不可用”。如何使用PCLStorage在两种平台上存储文件?或者我还有别的办法吗?下面是我的一些代码的示例: public async Task CreateRealFileAsync(string filenam

我正在用xamarin为Android和iOS编写一个跨平台应用程序,我需要将一些文本文件保存到本地存储。我使用的是PCLstorage,但每当我将鼠标移到任何PCLstorage代码上时,它都会显示“MyApplication.Android:可用,MyApplication.iOS不可用”。如何使用PCLStorage在两种平台上存储文件?或者我还有别的办法吗?下面是我的一些代码的示例:

public async Task CreateRealFileAsync(string filename, string filebody)
    {
        // get hold of the file system
        IFolder rootFolder = FileSystem.Current.LocalStorage;

        // create a folder, if one does not exist already
        IFolder folder = await rootFolder.CreateFolderAsync("DadAppFiles", CreationCollisionOption.OpenIfExists);

        // create a file, overwriting any existing file
        IFile file = await folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

        // populate the file with some text
        await file.WriteAllTextAsync(filebody);
    }

确保在所有平台上安装nuget软件包。我还假设此处显示的代码是在PCL中,而不是在特定于平台的项目中。@YuriS我使用命令“Install package PCLStorage-Version 1.0.2”安装了该包。当我再次尝试执行它时,它说它已经存在于两个项目中。您是正确的,代码不在特定于平台的项目中。您是否尝试在两个平台上运行它?可能只是智能感知错误?顺便说一句,它应该说它存在于3个项目中,而不是2个。使用Nuget manager UII检查它的安装位置我还无法在iOS上测试它。当我使用Nuget UI时,只有两个项目可以安装到MyApplication.Android和MyApplication.iOS。第三个项目是什么?你使用PCL还是共享项目?