I want to delete all file in camera folder of my internal smartphone's storage before it goes off!
How can i do?
namespace App1
{
[Activity(Label = "App1", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView (Resource.Layout.Main);
Button delete = FindViewById<Button>(Resource.Id.deleteid);
delete.Click += delegate
{
File dir = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryDcim), "/Camera");
if (dir.IsDirectory)
{
int i = 0;
string[] children = dir.List();
while ( i < children.Length)
{
var file = new File(dir, children[i]).Delete();
i++;
}
Toast.MakeText(this, "The folder exist", ToastLength.Short).Show();
}
else
{
Toast.MakeText(this, "Not Works", ToastLength.Short).Show();
}
};
}
}
}
I tried to use this code to delete the content of folder but the app crashes.