OS Error: Not a directory when creating a directory in temporary directory

59 Views Asked by At

I'm trying to create a directory in my temp / cache directory to store a file after downloading it but I seem to keep getting the Creation failed, path = 'xxxxx' (OS Error: Not a directory, errno = 20) error

createDirectory(String name) async {
  final fileDir = await getTemporaryDirectory();
  final Directory newFileDir = await Directory('${fileDir.path}/$name').create(recursive: true);
}

I tried getApplicationCacheDirectory() too but I got the same error but when I changed use getApplicationDocumentsDirectory(), it manage to create the directory without any error. Am I missing anything or is it not allowed to create a directory in the temp directory?

0

There are 0 best solutions below