Unable to load file using PCL Storage in PCL project

I am trying to get file which is added in PCL project as below:

   IFile file = await PCLStorage.FileSystem.Current.GetFileFromPathAsync("ProjectName.Data.AuthRequest.json");

Above is always returning null. BuildAction is set to Embedded Resource

Answers

  • JamesMontemagnoJamesMontemagno USForum Administrator, Xamarin Team, Developer Group Leader Xamurai

    You most likely need the embedded resource plugin: https://github.com/JosephHill/EmbeddedResourcePlugin

    PCL Storage is for File IO

  • Without using any plugin, following code working fine.

        var assem = typeof(Class).GetTypeInfo().Assembly;
    
                        Stream stream = assem.GetManifestResourceStream(string.Format("ProjectName.CustomFolder.FileName"));
    
                        using (var reader = new System.IO.StreamReader(stream))
                        {
                            text = reader.ReadToEnd();
                        }
    
Sign In or Register to comment.