I am testing about
- Create A folder.
- Upload files in the A folder.
- Delete files in the A folder.
- Delete A folder.
1-3 steps are fine.
But I got an error from the 4 step.
PathAccessException: Cannot delete file, path = 'folder' (OS Error: Access is denied.
, errno = 5)
So, one solution I want is setting folder permission to remove it.
This is what I think:
- Create A folder.
- Upload files in the A folder.
- Delete files in the A folder.
- Set permission of A folder.
- Delete A folder.
But I found GitHub issue. They will not add a setting permission feature. So, is there any solution to delete this folder by using the Dart server?
This is my code about creating a new folder:
bool? createFolder(String path) {
try {
final folder = Directory(path);
if (folder.existsSync()) return null;
folder.createSync(recursive: false);
if (!folder.existsSync()) return false;
return true;
} catch (e) {
print('Error:n$e');
return false;
}
}
and the delete folder function:
bool deleteFolder(String path) {
try {
final directory = Directory(path);
if (directory.existsSync()) File(path).deleteSync();
if (directory.existsSync()) return false;
return true;
} catch (e) {
print('Error:n$e');
return false;
}
}
PS. I found GitHub issue.