Reputation: 7063
I am new to Xamarin.Forms, and want to save some files like CSV, PDF in the device using Export to CSV / PDF.
And to do that I need to access device directory and path. But using Xamarin.Forms, How can I access directory and path in Xamarin.Forms for iOS & Android?
Thanks in advance!
Upvotes: 2
Views: 7465
Reputation: 56
System.Environment.GetFolderPath cannot be used with PCL project.(But shared project,It can) If you plan to use PCL path, You can use 'Dependency Service' Feature.
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/dependency-service/
use Interface(on PCL) that inject from Concrete Class (From iOS/Android). (Sound Hard,But It's easy)
Upvotes: 4
Reputation: 4746
You could use System.Environment.GetFolderPath to help with things such as this.
i.e.:-
string strFolderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
In Android this will return something along the lines of /data/data/MyProject/files
You can then just append your filename onto the end and then start creating and writing to the file etc.
Upvotes: 2