[mono-android] Deleting files on external storage?

Morten Nilsen mortenn at hapro.no
Tue Mar 29 04:57:30 EDT 2011


Hello,
I expect you might find http://developer.android.com/reference/android/Manifest.permission.html useful in this instance..

  -- Cheers, Morten

From: monodroid-bounces at lists.ximian.com [mailto:monodroid-bounces at lists.ximian.com] On Behalf Of Jon Valvatne
Sent: Tuesday, March 29, 2011 10:52 AM
To: Monodroid at lists.ximian.com
Subject: [mono-android] Deleting files on external storage?

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/a4df2132/attachment.html 


More information about the Monodroid mailing list