How to create a folder programmatically and transfer installed applications to this folder

I have two separate applications. When I install them on the device, they are displayed as normal applications. But when I launch the application for the first time, I want to create a folder and move these two applications to this folder. I know that we can do this when we drag the first application to another application using drag and drop. But I want to do it automatically.

+4
source share
1 answer
NSError *ferr;
            NSString *filename = [NSString stringWithFormat:@"RecordFile_%@.txt",donation_rec_id_str];
            NSString *destination_path = [self DocumentDirectory];
            destination_path = [destination_path stringByAppendingString:@"/Record_Backup"];

            //Create folder
            if (![[NSFileManager defaultManager] fileExistsAtPath:destination_path])
                [[NSFileManager defaultManager] createDirectoryAtPath:destination_path withIntermediateDirectories:NO attributes:nil error:&ferr];

            destination_path = [destination_path stringByAppendingPathComponent:filename];
            NSLog(@"FULL PATH:%@",destination_path);

            //MOVE/RENAME FILE
            if ( [[NSFileManager defaultManager] isReadableFileAtPath:source_filepath] ){
                [[NSFileManager defaultManager] copyItemAtPath:source_filepath toPath:destination_path error:NULL];
            }
0
source

Source: https://habr.com/ru/post/1532765/


All Articles