1 Reply
      Latest reply on Sep 10, 2019 1:39 AM by eskimo
      GaneshaBSUG Level 1 Level 1 (0 points)

        one of our clients stored to many files as it seems.


        following CODE:


        +(NSArray *)setDirContent

        {   //load Content of User Directory in file

            NSDate *logFileDate  = [NSDate date];

            NSString *dirCont = [NSString stringWithFormat:@"%@ created: %@\n\n",DIRCONTENT,logFileDate];


            NSString *resourcePath = [self getSystemDirectory];

            NSError *error;


            NSFileManager *fileManager = [NSFileManager defaultManager];

            NSArray *directoryContents = [fileManager contentsOfDirectoryAtPath:resourcePath error:&error];

            for (int i=0;i<directoryContents.count;i++)


                dirCont = [NSString stringWithFormat:@"%@,\n%@",dirCont,directoryContents[i]];


            NSString *statFilePath = [NSString stringWithFormat: @"%@%@%@",[self getClientDirectory],DIRCONTENT,TXTFILE];

            NSData *fileContent = [dirCont dataUsingEncoding:NSUTF8StringEncoding];

            NSFileHandle *handle;

            handle = [NSFileHandle fileHandleForWritingAtPath: statFilePath];

            [fileManager createFileAtPath: statFilePath contents:fileContent attributes:nil];


            return directoryContents;



        READS      the directory content and stores it into a file.


        but since a few weeks for one client the app can not execute this code any longer because the app crashes.


        What could we do to get the content of the directory into a file?


        Thanks for your ideas !