I try to copy a file that is included in the app bundle as a resource to the temp folder on the iPhone. While this works on the Simulator, on the device I get an exception:
System.UnauthorizedAccessException: Access to the path "/private/var/mobile/Applications/B763C127-9882-4F76-8860-204AFEA8DD68/Client_iOS.app/testbundle.zip" is denied.
The code I use is below It cannot open the source file.
using(var sourceStream = File.Open("./demobundle.zip", FileMode.Open))
{
sourceStream.CopyTo(targetStream);
}
What is the correct way of copying a file into a destination stream?