Code Block:
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:
flutter: Error: PathAccessException: Cannot rename file to '/Users/dhavalkansara/Documents/dummy copy 8.pdf', path = '/Users/dhavalkansara/Library/Containers/com.myapp.apps/Data/Library/Caches/encryption-decryption/dummy copy 8.pdf.txt' (OS Error: Operation not permitted, errno = 1)
My Settings with the App Sandbox Capabilities:
Code Block:
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:
flutter: Error: PathAccessException: Cannot rename file to '/Users/dhavalkansara/Documents/dummy copy 8.pdf', path = '/Users/dhavalkansara/Library/Containers/com.myapp.apps/Data/Library/Caches/encryption-decryption/dummy copy 8.pdf.txt' (OS Error: Operation not permitted, errno = 1)
My Settings with the App Sandbox Capabilities:
Share Improve this question edited yesterday Dhaval Kansara asked Feb 7 at 13:39 Dhaval KansaraDhaval Kansara 3,9115 gold badges25 silver badges51 bronze badges 2- You’ll need to ask the user first for access and permission using an openpanel. developer.apple.com/documentation/security/… – mahal tertin Commented Feb 8 at 7:37
- It seems like this question simply says "I turned on sandboxing for my app, and was amazed to discover that from then on my app was sandboxed". – matt Commented 2 days ago
1 Answer
Reset to default -1import 'dart:io';
void moveFile() async {
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);
// Copy the file first, then delete the original.
await file.copy(newPath);
await file.delete();
print('File moved successfully');
} catch (e) {
print('Error: $e');
}
}