最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ios - Not able to renamemove file after adding sandbox capabilities in my Flutter Mac Application - Stack Overflow

programmeradmin5浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default -1
import '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');
    }
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论