filesystemexception:创建失败,路径='目录:'' (OS错误:仅读取文件系统,ERRNO = 30)
我正在收到错误作为未经手的异常:fileSystemexception:创建失败,path ='directory:''(OS错误:仅读取文件系统,errno = 30)
当我尝试保存XLSX时文件。
代码:
class ExportPasswords {
static exportUserEntries(List entries) async {
final _psd = PasswordDecrypter();
final _secureStorage = FlutterSecureStorage();
//creating the xlsx
var excel = Excel.createExcel();
var fileBytes = excel.save();
Sheet sheetObject = excel['pssswd_export'];
CellStyle cellStyle = CellStyle(
backgroundColorHex: "#1AFF1A",
fontFamily: getFontFamily(FontFamily.Calibri));
cellStyle.underline = Underline.Single;
for (var entry in entries) {
final _username = entry['data']['username'];
final _name = entry['data']['name'];
final _url = entry['data']['url'];
final _hashedPassword = entry['data']['password'];
final _randForKeyToStore = entry['data']['randForKeyToStore'];
final _randForIV = entry['data']['randForIV'];
final _masterPassword = await _secureStorage.read(key: 'masterPassword');
final _decryptedEntryPassword = await _psd.getDecryptedPassword(
_hashedPassword, _randForKeyToStore, _randForIV, _masterPassword);
sheetObject.appendRow([_name, _username, _decryptedEntryPassword, _url]);
}
PermissionStatus permissionResult =
await SimplePermissions.requestPermission(
Permission.WriteExternalStorage);
if (permissionResult == PermissionStatus.authorized) {
Directory directory = await getApplicationDocumentsDirectory();
// print(directory);
new Directory(directory.path + '/').create(recursive: true).then((dir) {
print(dir);
File(join('$dir/pssswd_export'))
..createSync(recursive: true)
..writeAsBytesSync(fileBytes!);
});
}
}
}
我已获得write_external_storage的许可。
I/SimplePermission( 7685): Requesting permission : android.permission.WRITE_EXTERNAL_STORAGE
I/SimplePermission( 7685): Requesting permission status : 3
在错误中,它显示为目录:''
,但是当我打印目录值时,它将显示路径
I/flutter ( 7685): Directory: '/data/user/0/com.palsoham.pssswd.pssswd/app_flutter/'
I am receiving an error as Unhandled Exception: FileSystemException: Creation failed, path = 'Directory: '' (OS Error: Read-only file system, errno = 30)
when I am trying to save a xlsx file.
Code:
class ExportPasswords {
static exportUserEntries(List entries) async {
final _psd = PasswordDecrypter();
final _secureStorage = FlutterSecureStorage();
//creating the xlsx
var excel = Excel.createExcel();
var fileBytes = excel.save();
Sheet sheetObject = excel['pssswd_export'];
CellStyle cellStyle = CellStyle(
backgroundColorHex: "#1AFF1A",
fontFamily: getFontFamily(FontFamily.Calibri));
cellStyle.underline = Underline.Single;
for (var entry in entries) {
final _username = entry['data']['username'];
final _name = entry['data']['name'];
final _url = entry['data']['url'];
final _hashedPassword = entry['data']['password'];
final _randForKeyToStore = entry['data']['randForKeyToStore'];
final _randForIV = entry['data']['randForIV'];
final _masterPassword = await _secureStorage.read(key: 'masterPassword');
final _decryptedEntryPassword = await _psd.getDecryptedPassword(
_hashedPassword, _randForKeyToStore, _randForIV, _masterPassword);
sheetObject.appendRow([_name, _username, _decryptedEntryPassword, _url]);
}
PermissionStatus permissionResult =
await SimplePermissions.requestPermission(
Permission.WriteExternalStorage);
if (permissionResult == PermissionStatus.authorized) {
Directory directory = await getApplicationDocumentsDirectory();
// print(directory);
new Directory(directory.path + '/').create(recursive: true).then((dir) {
print(dir);
File(join('$dir/pssswd_export'))
..createSync(recursive: true)
..writeAsBytesSync(fileBytes!);
});
}
}
}
I have given the permission of WRITE_EXTERNAL_STORAGE.
I/SimplePermission( 7685): Requesting permission : android.permission.WRITE_EXTERNAL_STORAGE
I/SimplePermission( 7685): Requesting permission status : 3
In the error it is displayed as Directory : ''
, but when I am printing the directory value it is showing the path
I/flutter ( 7685): Directory: '/data/user/0/com.palsoham.pssswd.pssswd/app_flutter/'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请尝试从
文件
函数中更改路径,从'$/pssswd_export'
到dir.dir.path +/pssswd_export'
。Please try changing your path in
File
function from'$dir/pssswd_export'
todir.path + /pssswd_export'
.