代码块:
String originalPath = '/Users/dhavalkansara/Library/Containers/com.myapp.apps/Data/Library/Caches/encryption-decryption/dummy copy 8.pdf.txt';
String newPath = '/Users/dhavalkansara/Documents/dummy copy 8.pdf';
try {
File file = File(originalPath);
await file.rename(newPath);
print('File moved successfully');
} catch (e) {
print('Error: $e');
}
eRror:
快报:错误:PathaccessException:无法将文件重命名为 '/users/dhavalkansara/documents/dummy copy 8.pdf',path = '/users/dhavalkansara/library/containers/com.myapp.apps/data/library/caches/cencryption-decryptimption/dummy 复制8.pdf.txt'(OS错误:不允许操作,ERRNO = 1)
我具有应用沙盒功能的设置:
Import'Dart:io';
void movefile()async { 字符串原始路径='/users/dhavalkansara/library/containers/com.myapp.apps/data/library/caches/encryption-decryption/dummy/dummy copy 8.pdf.txt'; 字符串newPath ='/users/dhavalkansara/documents/dummy copy 8.pdf';
try {
File file = File(originalPath);
// Copy the file first, then delete the original.
await file.copy(newPath);
await file.delete();
print('File moved successfully');
} catch (e) {
print('Error: $e');
}
}