Я хотел бы сохранить файл doc в zip-файле в каталоге документа, и когда пользователь захочет, он может подключить его по электронной почте. Я создал zip-файл, но когда я хочу его снова открыть, он создает zipfile, zip.cpgz
вместо testing.zip
.Заблокировать файл doc в ios и сохранить в каталоге документов
Вот мой код для создания архива
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSArray *filePathsArray = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:documentsDirectory error:nil];
int index =0;
for (NSString *item in filePathsArray){
if ([[item pathExtension] isEqualToString:@"doc"])
{
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[filePathsArray objectAtIndex:index]];
//NSString *FileName=[stringPath1 stringByAppendingPathComponent:@"Console.doc"];
NSString *stringPath=[documentsDirectory stringByAppendingPathComponent:[@"testing" stringByAppendingFormat:@".zip"]];
ZipFile *zipFile = [[ZipFile alloc]initWithFileName:stringPath mode:ZipFileModeCreate];
ZipWriteStream *stream= [zipFile writeFileInZipWithName:@"doc" compressionLevel:ZipCompressionLevelBest];
NSData *data = [NSData dataWithContentsOfFile:filePath];
[stream writeData:data];
[stream finishedWriting];
}
}
Непонятно, что вы хотите. Перепишите это. – trojanfoe
На самом деле я хочу сжать файл документа и сохранить его, чтобы сделать каталог документов – RaviJSS