jace
jace

Reputation: 1674

Failed making directory in external storage in android

I have this method but why is it failing to create a directory in pictures folder?

    private void CreateDirectoryForPictures()
    {
        App._dir = new File(
            Android.OS.Environment.GetExternalStoragePublicDirectory(
                Android.OS.Environment.DirectoryPictures), "CameraAppDemo");
        if (!App._dir.Exists())
        {
            App._dir.Mkdirs();
        }
        if (!App._dir.Exists())
        {
            Toast.MakeText(this, "Directory not created", ToastLength.Short).Show();
        }
        else
        {
            Toast.MakeText(this, "Directory created", ToastLength.Short).Show();
        }

    }

Upvotes: 1

Views: 661

Answers (1)

Shubham Rana
Shubham Rana

Reputation: 410

Have you added the WRITE_EXTERNAL_STORAGE permission in the manifest?

Upvotes: 3

Related Questions