【发布时间】:2014-03-21 10:18:33
【问题描述】:
在我的应用程序中,我正在截取图像视图的屏幕截图,然后将这些屏幕截图保存在应用程序的文档文件夹中。现在我想通过电子邮件发送所有具有相同文件夹结构的图像。压缩所有文件夹包含图片?
-(void)ZipFile2{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [paths objectAtIndex:0];
BOOL isDir=NO;
NSArray *subpaths;
NSString *exportPath = docDirectory;
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:exportPath isDirectory:&isDir] && isDir){
subpaths = [fileManager subpathsAtPath:exportPath];
}
NSString *archivePath = [docDirectory stringByAppendingString:@"Uploads.zip"];
ZipArchive *archiver = [[ZipArchive alloc] init];
[archiver CreateZipFile2:archivePath];
for(NSString *path in subpaths)
{
NSString *longPath = [exportPath stringByAppendingPathComponent:path];
if([fileManager fileExistsAtPath:longPath isDirectory:&isDir] && !isDir)
{
[archiver addFileToZip:longPath newname:path];
}
}
BOOL successCompressing = [archiver CloseZipFile2];
if(successCompressing)
NSLog(@"Success");
else
NSLog(@"Fail");
}
我使用此代码,但我的 Ipad 中没有创建 zip 文件 ???你能帮帮我吗
【问题讨论】:
标签: objective-c ipad ios7 zip xcode5