【问题标题】:In Flutter, How to open a folder in native file explorer for the user, so that the user can browse its files/folders在 Flutter 中,如何在本机文件资源管理器中为用户打开一个文件夹,以便用户可以浏览其文件/文件夹
【发布时间】:2020-11-24 07:40:25
【问题描述】:

我正在 Flutter 中构建一个文件锁应用程序,它可以锁定文件和文件夹。当用户解锁文件夹时,我希望我的应用程序显示查看文件夹内容的选项,但在本机文件资源管理器中。有没有办法实现这个功能?

(提前谢谢..)

【问题讨论】:

  • 看看file_picker
  • 它用于挑选文件。我想用特定路径打开文件管理器(全部在 dart 中以编程方式)
  • 您的意思是启动本机文件资源管理器吗?在这种情况下,用户不能直接访问本机文件资源管理器而不是通过您的应用程序吗?
  • @RiturajShakti 你找到解决方案了吗?我希望用户能够打开一个保存应用相关文件的特定文件夹。 open_file 包目前还不支持。

标签: android file flutter dart directory


【解决方案1】:

您可以针对您提到的用例尝试此包:open_file

用法:

import 'package:open_file/open_file.dart';
import 'package:path_provider/path_provider.dart';

//Get the path to the directory
final String dir = (await getTemporaryDirectory()).path;

//Use the path to launch the directory with the native file explorer
await OpenFile.open('$dir\\');

(注意:仅在 Windows 操作系统上测试)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-11
    • 1970-01-01
    • 1970-01-01
    • 2010-09-24
    • 1970-01-01
    • 1970-01-01
    • 2020-10-17
    • 1970-01-01
    相关资源
    最近更新 更多