Yog*_*ogi 8 iphone zip objective-c ipad mfmailcomposeviewcontroller
在我的应用程序中,我正在截取图像View的截图,然后我将这些屏幕截图保存在应用程序的文档文件夹中.现在我想通过电子邮件发送所有这些图像,它们具有相同的文件夹结构.压缩包含图像的所有文件夹然后将zip文件附加到邮件将解决问题,但我如何压缩这些文件夹,然后将它们附加到邮件?
任何帮助表示赞赏!
Rob*_*bin 18
我已经使用此代码创建了我的应用程序的文档目录的zip文件,它工作
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:@"/test.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];
}
}
if([archiver CloseZipFile2])
NSLog(@"Success");
else
NSLog(@"Fail");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13662 次 |
| 最近记录: |