flutter-permission-handler icon indicating copy to clipboard operation
flutter-permission-handler copied to clipboard

folder not created its gives error Creation failed (OS Error: Operation not permitted, errno = 1)

Open codermonk1 opened this issue 3 years ago • 3 comments

💬 Questions and Help

In my project, the folder has created when splash screen run ,below android 10 version, now i have android 11 in this its give error Creation failed, path = 'storage/emulated/0/folder_name' (OS Error: Operation not permitted, errno = 1)

Need help....

codermonk1 avatar Apr 14 '22 05:04 codermonk1

me too,In my project,below android 11

sunqihui222 avatar May 30 '22 02:05 sunqihui222

I found resolution in this https://stackoverflow.com/questions/69592763/cant-write-to-file-in-flutter

maplerder avatar Jul 01 '22 09:07 maplerder

Hi @codermonk1, @sunqihui222, did the solution provided by maplerder work for you? as mentioned in the StackOverflow post, manageExternalStorage is a risky permission where you have to fill in a form if you want to publish the app. the link to the form can be found at the Permission.manageExternalStorage permissions documentation.

JDDV avatar Jul 29 '22 07:07 JDDV

FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1)

in Android 11 & 12 in this error showing, please give solution

KrunalNathani avatar Sep 24 '22 10:09 KrunalNathani

FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1)

in Android 11 & 12 in this error showing, please give solution

Have u fixed it?

TranDinhNhatTri avatar Nov 02 '22 03:11 TranDinhNhatTri

Yes

On Wed, Nov 2, 2022, 9:14 AM TranDinhNhatTri @.***> wrote:

FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1)

in Android 11 & 12 in this error showing, please give solution

Have u fixed it?

— Reply to this email directly, view it on GitHub https://github.com/Baseflow/flutter-permission-handler/issues/833#issuecomment-1299524541, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWHZDMHSSNBXNFIBPGVPTWGHPRXANCNFSM5TMWJKKQ . You are receiving this because you were mentioned.Message ID: @.***>

codermonk1 avatar Nov 03 '22 09:11 codermonk1

You can make folder under the system folder For example '/storage/emulated/0/DCIM/yourfoldername

On Sat, Sep 24, 2022, 4:22 PM KrunalNathani @.***> wrote:

FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1)

in Android 11 & 12 in this error showing, please give solution

— Reply to this email directly, view it on GitHub https://github.com/Baseflow/flutter-permission-handler/issues/833#issuecomment-1256937898, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWHZAM3AI5S4X2DNUOA73V73MN7ANCNFSM5TMWJKKQ . You are receiving this because you were mentioned.Message ID: @.***>

codermonk1 avatar Nov 03 '22 09:11 codermonk1

FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1)

in Android 11 & 12 in this error showing, please give solution

When using the Date & Time as part of the file name, do not include the semicolon(:) in the time field. You must remove the semicolon and change it to a hyphen (-)

Example: 
'/storage/emulated/0/New Project/v_2022-09-24 16-17-52.109373'

developer-nesamani avatar Feb 08 '23 12:02 developer-nesamani

FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1)

in Android 11 & 12 in this error showing, please give solution

did you find any solutions? im also facing the same issue. my app works fine on android version < 11.

Muazzy avatar Mar 24 '23 15:03 Muazzy

Yes, I did.

On Fri, Mar 24, 2023, 8:50 PM Muazzam @.***> wrote:

FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1)

in Android 11 & 12 in this error showing, please give solution

did you find any solutions? im also facing the same issue. my app works fine on android version < 11.

— Reply to this email directly, view it on GitHub https://github.com/Baseflow/flutter-permission-handler/issues/833#issuecomment-1482983582, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWHZFDCASWBYBX7UUWCVDW5W3TTANCNFSM5TMWJKKQ . You are receiving this because you were mentioned.Message ID: @.***>

codermonk1 avatar Mar 24 '23 15:03 codermonk1

Yes, I did. On Fri, Mar 24, 2023, 8:50 PM Muazzam @.> wrote: FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1) in Android 11 & 12 in this error showing, please give solution did you find any solutions? im also facing the same issue. my app works fine on android version < 11. — Reply to this email directly, view it on GitHub <#833 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWHZFDCASWBYBX7UUWCVDW5W3TTANCNFSM5TMWJKKQ . You are receiving this because you were mentioned.Message ID: @.>

can you please provide your solution?

Muazzy avatar Mar 24 '23 19:03 Muazzy

@Muazzy see comment by mahee510

yshean avatar Mar 28 '23 06:03 yshean

you should use or create the folder inside the system folder which is created by android

for example you create folder name xyz then you should create this folder inside DCIM folder or in PICTURE folder ... any system folder... for exam code.. createFolder() async { PermissionStatus permissionResult = await Permission.storage.request(); if (permissionResult == PermissionStatus.granted) { new Directory('/storage/emulated/0/DCIM/(your folder name)') .create() // The created directory is returned as a Future. .then((Directory directory) {}); } }

On Tue, Mar 28, 2023 at 12:00 PM Yong Shean @.***> wrote:

@Muazzy https://github.com/Muazzy see comment by mahee510

— Reply to this email directly, view it on GitHub https://github.com/Baseflow/flutter-permission-handler/issues/833#issuecomment-1486289092, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWHZFWY6HWTW3FXDZMFPDW6KARTANCNFSM5TMWJKKQ . You are receiving this because you were mentioned.Message ID: @.***>

codermonk1 avatar Mar 28 '23 06:03 codermonk1

It worked.

On Tue, Mar 28, 2023 at 12:29 PM codermonk1 @.***> wrote:

you should use or create the folder inside the system folder which is created by android

for example you create folder name xyz then you should create this folder inside DCIM folder or in PICTURE folder ... any system folder... for exam code.. createFolder() async { PermissionStatus permissionResult = await Permission.storage.request(); if (permissionResult == PermissionStatus.granted) { new Directory('/storage/emulated/0/DCIM/(your folder name)') .create() // The created directory is returned as a Future. .then((Directory directory) {}); } }

On Tue, Mar 28, 2023 at 12:00 PM Yong Shean @.***> wrote:

@Muazzy https://github.com/Muazzy see comment by mahee510

— Reply to this email directly, view it on GitHub < https://github.com/Baseflow/flutter-permission-handler/issues/833#issuecomment-1486289092 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ARTWHZFWY6HWTW3FXDZMFPDW6KARTANCNFSM5TMWJKKQ

. You are receiving this because you were mentioned.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/Baseflow/flutter-permission-handler/issues/833#issuecomment-1486317998, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWHZAAP5FJ7UEFCU5RZTLW6KD4BANCNFSM5TMWJKKQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

codermonk1 avatar Mar 28 '23 07:03 codermonk1

It worked. On Tue, Mar 28, 2023 at 12:29 PM codermonk1 @.> wrote: you should use or create the folder inside the system folder which is created by android for example you create folder name xyz then you should create this folder inside DCIM folder or in PICTURE folder ... any system folder... for exam code.. createFolder() async { PermissionStatus permissionResult = await Permission.storage.request(); if (permissionResult == PermissionStatus.granted) { new Directory('/storage/emulated/0/DCIM/(your folder name)') .create() // The created directory is returned as a Future. .then((Directory directory) {}); } } On Tue, Mar 28, 2023 at 12:00 PM Yong Shean @.> wrote: > @Muazzy https://github.com/Muazzy see comment by mahee510 > > — > Reply to this email directly, view it on GitHub > < #833 (comment) >, > or unsubscribe > < https://github.com/notifications/unsubscribe-auth/ARTWHZFWY6HWTW3FXDZMFPDW6KARTANCNFSM5TMWJKKQ > > . > You are receiving this because you were mentioned.Message ID: > @.> > — Reply to this email directly, view it on GitHub <#833 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWHZAAP5FJ7UEFCU5RZTLW6KD4BANCNFSM5TMWJKKQ . You are receiving this because you are subscribed to this thread.Message ID: @.>

ok i will try this

Muazzy avatar Mar 28 '23 17:03 Muazzy

hi , did you find the solution ?, here is my case

var status = await Permission .storage .status;
if (!status.isGranted || await Permission.manageExternalStorage.request().isDenied) {
  await Permission .storage .request();
}

the i create a path like this

return File("/storage/emulated/0/Download/$filename");

after that i write to that storage loaction

await viewFile?.writeAsBytes(bytes);

i receive file as bytes, so its working file in most of the phones , got error in motog40 fusion, android version 12

shobith10 avatar May 04 '23 06:05 shobith10

i found the solution changing this way

Future getStoragePermission() async {
  PermissionStatus status = await Permission.storage.request();
  //PermissionStatus status1 = await Permission.accessMediaLocation.request();
  PermissionStatus status2 = await Permission.manageExternalStorage.request();
  print('status $status   -> $status2');
  if (status.isGranted && status2.isGranted) {
    return true;
  } else if (status.isPermanentlyDenied || status2.isPermanentlyDenied) {
    await openAppSettings();
  } else if (status.isDenied) {
    print('Permission Denied');
  }
}

shobith10 avatar May 04 '23 07:05 shobith10

FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1) in Android 11 & 12 in this error showing, please give solution

When using the Date & Time as part of the file name, do not include the semicolon(:) in the time field. You must remove the semicolon and change it to a hyphen (-)

Example: 
'/storage/emulated/0/New Project/v_2022-09-24 16-17-52.109373'

its worked for me thank u so much made my day

RezaKhajvand avatar Jun 06 '23 17:06 RezaKhajvand

Thank you @codermonk1 for opening this question. It appears that many people are wondering the same thing.

Thanks to everyone weighing in on the conversation. I feel like the question has been addressed sufficiently. The error is caused by an issue with creating the file, such as an invalid file name or a directory that the application is not allowed to access.

Future readers can look into this conversation to help them resolve their issues, or search online for help with writing files in Android.

JeroenWeener avatar Jun 29 '23 13:06 JeroenWeener

FileSystemException: Cannot create file, path = '/storage/emulated/0/New Project/v_2022-09-24 16:17:52.109373' (OS Error: Operation not permitted, errno = 1) in Android 11 & 12 in this error showing, please give solution

When using the Date & Time as part of the file name, do not include the semicolon(:) in the time field. You must remove the semicolon and change it to a hyphen (-)

Example: 
'/storage/emulated/0/New Project/v_2022-09-24 16-17-52.109373'

Thank you for the solution. It's work for me.

thakaredipali avatar Jul 28 '23 12:07 thakaredipali