Bug 49606 - System.IO.Directory.CreateDirectory gives System.UnauthorizedAccessException: Access to the path "...." is denied.
Summary: System.IO.Directory.CreateDirectory gives System.UnauthorizedAccessException:...
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: unspecified
Hardware: Other Other
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-12-11 14:46 UTC by Abi
Modified: 2016-12-11 17:18 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Exception Screenshot (35.15 KB, image/jpeg)
2016-12-11 14:46 UTC, Abi
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Abi 2016-12-11 14:46:14 UTC
Created attachment 18857 [details]
Exception Screenshot

Hi,

I m trying to create a folder in external memory using below code, which is giving 'System.UnauthorizedAccessException: Access to the path "/storage/emulated/0/testFolder/"' is denied exception when setting android:targetSdkVersion="23"

Code:
-----
string folderPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/testFolder/";
if (!System.IO.Directory.Exists(folderPath))
{
  System.IO.Directory.CreateDirectory(folderPath);
}

Note:
I already set following in manifest to requestAccess:
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Thanks