Flutter无法创建目录(操作系统错误:只读文件系统) [英] Flutter Unable to create directory (OS Error: Read-only file system)

查看:569
本文介绍了Flutter无法创建目录(操作系统错误:只读文件系统)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注-如何从 https://docs创建目录.flutter.io/flutter/dart-io/Directory-class.html

new Directory('dir/subdir').create(recursive: true)
  // The created directory is returned as a Future.
  .then((Directory directory) {
    print(directory.path);
});

这是我得到的错误:

FileSystemException:创建失败,路径='dir'(操作系统错误:只读文件系统,errno = 30)

FileSystemException: Creation failed, path = 'dir' (OS Error: Read-only file system, errno = 30)

我已启用 Storage(WRITE_EXTERNAL_STORAGE)权限.(Android设备)

I have enabled Storage(WRITE_EXTERNAL_STORAGE) permission. (Android device)

我想念什么?

推荐答案

了解它(使用path_provider插件获取正确的路径)

Got it (Using path_provider plugin to get correct path)

Directory appDocDirectory = await getApplicationDocumentsDirectory();

new Directory(appDocDirectory.path+'/'+'dir').create(recursive: true)
// The created directory is returned as a Future.
    .then((Directory directory) {
  print('Path of New Dir: '+directory.path);
});

这篇关于Flutter无法创建目录(操作系统错误:只读文件系统)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆