1
我想在應用程序首次啓動時自動將項目資源文件夾中的文件組複製到應用程序文檔文件夾。我可以這樣做嗎?我需要通過代碼來完成嗎?自動將文件複製到應用程序文檔文件夾
我想在應用程序首次啓動時自動將項目資源文件夾中的文件組複製到應用程序文檔文件夾。我可以這樣做嗎?我需要通過代碼來完成嗎?自動將文件複製到應用程序文檔文件夾
BOOL success;
NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"Data.txt"];
success = [fileManager fileExistsAtPath:filePath];
if (!success) {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"txt"];
success = [fileManager copyItemAtPath:path toPath:filePath error:&error];
}
在應用做了與選項
完成啓動是的,你可以做到這一點。是的,你需要在代碼中完成。 –