Flutter Unzip文件夹为空(Flutter_archive 4.2.0)

发布于 2025-01-24 13:05:03 字数 683 浏览 2 评论 0原文

在以下代码中,我选择了设备下载文件夹中的filepicker的zip文件,我说提取点将是同一文件夹,但是当我选择文件并执行提取过程时,日志中的所有内容看起来都很完美,但是当我访问创建的目录时,它说它是空的。我附上代码:

FilePickerResult? result = await FilePicker.platform.pickFiles();

    if (result != null) {
      final zip = File(result.files.single.path.toString());
      final unZip = Directory("/storage/emulated/0/Download");
      print(unZip.path.toString());
      print(zip);
      try{
        ZipFile.extractToDirectory(zipFile: zip, destinationDir: unZip);
      }catch(e){
        print(e);
      }

这些是我在AndroidManifest中分配的权限:

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

In the following code I select a zip file with filePicker that is in the downloads folder of the device, I say that the extraction point will be the same folder but when I select the file and perform the extraction process, everything in the log looks perfect, but when I access the created directory it says that it is empty. I attach the code:

FilePickerResult? result = await FilePicker.platform.pickFiles();

    if (result != null) {
      final zip = File(result.files.single.path.toString());
      final unZip = Directory("/storage/emulated/0/Download");
      print(unZip.path.toString());
      print(zip);
      try{
        ZipFile.extractToDirectory(zipFile: zip, destinationDir: unZip);
      }catch(e){
        print(e);
      }

These are the permissions that I have assigned in my AndroidManifest:

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十秒萌定你 2025-01-31 13:05:03

尝试使用它

final tempDir = await getTemporaryDirectory();
final unZip = Directory('${tempDir.path}/Download');

而不是这个

final unZip = Directory("/storage/emulated/0/Download");

Try using this

final tempDir = await getTemporaryDirectory();
final unZip = Directory('${tempDir.path}/Download');

instead of this

final unZip = Directory("/storage/emulated/0/Download");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文