0

How can I detect the "Downloads" folder in Xamarin forms? And do I need specific rights? I cannot find a matching variable on this in GetFolderPath() nor FileSystemHelper. Thx

FreakyAli
  • 10,567
  • 3
  • 19
  • 50

1 Answers1

1

In android, from external files, we can get Downloads folder by following code:

 string path1 = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, Android.OS.Environment.DirectoryDownloads);

The path like /storage/emulated/0/Download/

In ios, use this directory to store user documents and application data files.

var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);

If you want to add or modify file in Download folder, you need request permissions in Android platform.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

There is one thread that you can take a look:

How to open PDF file in xamarin forms

Cherry Bu - MSFT
  • 9,528
  • 1
  • 8
  • 15
  • 1
    Beware of the new Android 11 MANAGE_EXTERNAL_STORAGE permission that is needed. WRITE_EXTERNAL_STORAGE will be completely ignored with Android 11. (With Android 10 and android:requestLegacyExternalStorage="true" in manifest it would still work.) – thomiel Mar 14 '22 at 14:00