2014-09-22 9 views
-1

Я создал файл базы данных, используя следующий кодКак удалить файл, который создается в папке Document

// Get the documents directory 
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *docsDir = dirPaths[0]; 

// Build the path to the database file 


databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent:@"MyDB.db"]]; 

Как я могу удалить файл «MyDB.db»?

Заранее спасибо.

+0

Пожалуйста, немного поиска, прежде чем отправлять вопрос. – rmaddy

ответ

1

Вы можете удалить файл со следующим

NSError *error; 
if(![[NSFileManager defaultManager] removeItemAtPath:databasePath error:&error]) { 
    NSLog(@"error while removing file: %@", error.localizedDescription); 
}