[mono-android] Deleting files on external storage?

Jon Valvatne jon at norsync.com
Tue Mar 29 04:51:51 EDT 2011


I seem to be unable to create an app that deletes files off the SD card -
even files created by that same app. A simple test case is a default
MonoAndroidApplication with these two lines inserted in Activity1.onCreate:

                System.IO.File.Create("/sdcard/test.txt");
                System.IO.File.Delete("/sdcard/test.txt");

The Create works fine, but the Delete fails with a
System.UnauthorizedAccessException: Access to the path "/sdcard/test.txt" is
denied.

I've tried figuring out if it may be a permissions problem, but it's a bit
tricky without knowing how the Android platform maps apps to users to
groups, since the default permission for all files and directories (at least
as viewed in the adb shell) seems to be 075. But either way, it seems
impossible that a permission problem should cause me to be able to create a
file but not delete it, since both operations should require the same
permission (that is, write permission to the containing directory).

Has anyone successfully deleted a file off external storage from C# code?

Thanks in advance,

Jon Valvatne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110329/8c8124d3/attachment.html 


More information about the Monodroid mailing list