【发布时间】:2014-06-16 14:00:23
【问题描述】:
当从邮件中打开 sqlite 文件时,它会出现在我的文档目录中名为收件箱的文件夹中 我使用此代码将此文件复制到文档目录
- (void) copyAdd
{
NSString *docsDir;
NSArray *dirPaths;
NSString *databasePath;
NSFileManager *filemgr = [NSFileManager defaultManager];
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSString* inboxPath = [docsDir stringByAppendingPathComponent:@"Inbox"];
// Build the path to the database file
databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"CAT.sqlite"]];
if(![filemgr fileExistsAtPath:databasePath]){
[filemgr copyItemAtPath:inboxPath toPath:databasePath error:nil];
NSLog( @"copy create database");
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"sucess" message:@"COPY CAT DB" delegate:self cancelButtonTitle:@"dismis" otherButtonTitles:nil, nil];
[alert show];
}else{
NSLog( @"Failed to open/create database");
}
它创建名为 CAT.sqlite 的文件夹,在这个文件夹中我找到了数据库 CAT.sqlite
如何在不创建同名文件夹的情况下将名为 CAT.sqlite 的文件从收件箱文件夹复制到文档目录。
【问题讨论】:
-
问题是什么?
-
需要将数据库复制到文档目录而不创建任何文件夹,并且收到新的同名数据库时需要从收件箱中删除旧数据库
-
如果您有特定的问题需要解决,那么这是您提出问题的正确网站。但是,我们不是在这里代表您实现功能;我们不为你工作。因此,请尝试使用您面临的具体问题来编辑您的问题,包括有关问题的详细信息以及您收到的任何错误消息。
-
我想我会问一些具体的事情,那就是为什么要创建文件夹而不是复制数据库,并且我输入了我使用的代码,所以如果你不知道为什么,请不要打扰我
-
您发布的代码尝试将
Indbox文件夹复制到名为CAT.sqlite的文件中。您需要Inbox文件夹中的文件路径,并且您想要移动该文件,而不是Inbox文件夹。
标签: ios objective-c sqlite