Here is my code:-
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *temp = @"Data to be written in file";
NSData *adata =[temp dataUsingEncoding:NSUTF8StringEncoding];
documentsDir = [documentsDir stringByAppendingPathComponent:@"/Document.docx"];
[adata writeToFile:documentsDir atomically:YES];
When i open this file in the document folder the problem that i face is that “File is invalid”. Can anyone help?
Thanks
docxfiles are zip-compressed XML documents with a layout defined by Microsoft. You can’t just write text out to a file, call it a docx and expect word to open it.