[Writer Writetofile:logpath atomically:YESThis is written in a file, and it's all covered-up.
atomically Yes or No:yes indicates that the file is written atomically, which means that a temporary file is created until the file content is successfully imported into the target file.
NO is written directly into the target file.
If you want to use an append file write, that is, the contents of the original file is not overwritten can be used Nsfilehandle:
1 #import2 intMainintargcConst Char*argv[])3 {4 @autoreleasepool {5 6Nsfilehandle *infile, *OutFile;7 8NSData *buffer;9 Ten One A //Open Filea for read operations - -InFile =[Nsfilehandle FILEHANDLEFORREADINGATP the - if(InFile = =Nil) - - { + -NSLog (@"Open of FileA.txt reading failed") + A return 1; at - } - - - - //Open Fileb for update operation in -OutFile = [Nsfilehandle filehandleforwritingatpath:@"FileB.txt"]; to + if(OutFile = =Nil) - the { * $NSLog (@"Open of Fileb for writing failed")Panax Notoginseng - return 2; the + } A the + - //Locate and navigate to the end of the outfile (append file after this) $ $ [OutFile seektoendoffile]; - - the - //read infile and write its contents to outfileWuyi theBuffer =[InFile readdatatoendoffile]; - Wu [OutFile Writedata:buffer]; - About $ //close Read and write files - - [InFile CloseFile]; - A [OutFile CloseFile]; + the } - $ return 0; the the}
Seektoendoffile returns the offset of the current file after the search operation has finished executing. Choose to ignore this value and, if necessary, use this information to get the file size in your program
WriteToFile and Nsfilehandle