Search code examples
c#xamarinxamarin.formsportable-class-libraryxamarin.uwp

How can I access only one specific method from the UWP class?


My application has a few pages with textboxes (I used xaml in PCL). I need to save the data that is typed in in an xml file. The problem is that there is no System.IO.FileStream (which I need in order to be able to save the data) method in PCL so I somehow need to get it from the native UWP class (the application should be running on a windows mobile 10). How do I do that? I've been suggested to use DependencyServices but how would I use it to get access to System.IO.Filestream in this case?

I'm sorry for using wrong terms, I'm a big noob who's watched multiple hours of xamarin tutorials but still struggels to get something done correctly.


Solution

  • One easy way is to use the PCLStorage NuGet library. It lets you read and write files from your PCL code is a cross platform way. You will have to add PCLStorage NuGet to your PCL project and any native project you want to access files in.