UnauthorizedAccessException on android
<p>I have an <code>UnauthorizedAccessException</code> on Android when trying to retrieve some files. The odd things is that it worked for months before this evening. </p>

<p>The only things I did the last couple of hours are (even if I can't see how it may have changed anything): </p>

<ul>
<li>uploading the apk to enable alpha testing the Google Play Services</li>
<li>adding a keystore and signing the app (tried with no signature, same problem)</li>
<li>removing last instance of my app on my test device (not compatible with the signed version)</li>
</ul>

<p>The app is built with Unity 5.5.0f3, I use <code>Application.persistentDataPath</code> to build the path I'm trying to access.</p>

<p>here is the callstack for the exception :</p>

<pre><code>UnauthorizedAccessException: Access to the path "/storage/emulated/0/Android/data/com.&lt;mycompany&gt;.&lt;myproductname&gt;/files/Saves" is denied.
at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in &lt;filename unknown&gt;:0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in &lt;filename unknown&gt;:0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern, SearchOption searchOption) [0x00000] in &lt;filename unknown&gt;:0
at ProfileManager.ParseDirForProfiles (.DirName _dir, .FileExtension _ext) [0x00000] in &lt;filename unknown&gt;:0
at SaveManager.ParseDirForProfiles () [0x00000] in &lt;filename unknown&gt;:0
at myproductname.OnStart () [0x00000] in &lt;filename unknown&gt;:0
at StateMachine.Start () [0x00000] in &lt;filename unknown&gt;:0
</code></pre>

<p><a href="https://i.stack.imgur.com/xeVjV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xeVjV.png" alt="CallStack"></a></p>

<p>The code causing problem :
<a href="https://i.stack.imgur.com/KH4qI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KH4qI.png" alt="Code"></a></p>

<p>and the relevant settings :
<a href="https://i.stack.imgur.com/uU3RU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uU3RU.png" alt="Settings 1"></a>
<a href="https://i.stack.imgur.com/TV3cz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TV3cz.png" alt="Settings 2"></a></p>