自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iOS應(yīng)用教程 實現(xiàn)文件拷貝

移動開發(fā) iOS
本文介紹的是iOS應(yīng)用教程 實現(xiàn)文件拷貝,主要是對文件的操作。我們來看內(nèi)容。

iOS應(yīng)用教程 實現(xiàn)文件拷貝是本文要介紹的內(nèi)容,由于ios文件對讀寫有限制,有關(guān)文件的讀寫描述,可以看iOS學(xué)習(xí)之路 文件操作。主要還是基于代碼實現(xiàn)

在實際開發(fā)中,我需要在工程中有一個sqlite數(shù)據(jù)庫文件,有相應(yīng)的數(shù)據(jù)結(jié)構(gòu)和初試數(shù)據(jù),在程序中應(yīng)用,在程序中又要對數(shù)據(jù)庫進行增加的操作,我們就需要把數(shù)據(jù)庫文件放到可以寫的目錄下,我采用的方法如下:

  1. -(void)copyFileDatabase   
  2. {   
  3.     NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,NSUserDomainMask, YES);   
  4.     NSString *documentsDirectory = [paths objectAtIndex:0];       
  5.     NSString *documentLibraryFolderPath = [documentsDirectory stringByAppendingPathComponent:@"elimimation"];   
  6.     if ([[NSFileManager defaultManager] fileExistsAtPath:documentLibraryFolderPath]) {   
  7.         NSLog(@"文件已經(jīng)存在了");   
  8.     }else {   
  9.         NSString *resourceSampleImagesFolderPath =[[NSBundle mainBundle]   
  10.                                                    pathForResource:@"elimimation"   
  11.                                                    ofType:@"sqlite"];   
  12.         NSData *mainBundleFile = [NSData dataWithContentsOfFile:resourceSampleImagesFolderPath];   
  13.         [[NSFileManager defaultManager] createFileAtPath:documentLibraryFolderPath   
  14.                                                     contents:mainBundleFile   
  15.                                                   attributes:nil];   
  16.     }  
  17.  
  18. }   
  19. -(void)deleteFileDatabade   
  20. {   
  21.     NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,NSUserDomainMask, YES);   
  22.     NSString *documentsDirectory = [paths objectAtIndex:0];       
  23.     NSString *documentLibraryFolderPath = [documentsDirectory stringByAppendingPathComponent:@"elimimation"];   
  24.     [[NSFileManager defaultManager] delete:documentLibraryFolderPath];   

小結(jié):iOS應(yīng)用教程 實現(xiàn)文件拷貝的內(nèi)容介紹完了,希望本文對你有所幫助!

轉(zhuǎn)自 http://wangjun.easymorse.com/?p=938

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-11-16 15:47:04

AdobeAIRiOS應(yīng)用

2010-02-06 17:09:29

C++文件拷貝

2011-07-08 14:58:16

iPhone Xcode iOS

2011-05-23 17:00:29

2021-11-24 08:41:52

BufferedWriJavaBufferedRea

2014-04-02 10:29:12

iOS 7模糊效果

2011-08-09 10:27:41

iOS剪貼板

2011-08-11 15:12:06

Xcode檢驗

2011-07-28 16:06:34

IOS 應(yīng)用程序 資源

2011-06-28 10:23:27

UIViewiOS

2012-01-18 13:51:39

2015-12-09 14:00:41

ios應(yīng)用

2018-09-26 14:37:17

JavaScript前端編程語言

2022-11-07 11:37:27

深拷貝淺拷貝底層

2011-07-28 09:49:50

IOS IOS 4 UI

2011-07-22 16:29:53

IOS Demo CD

2017-12-20 15:11:48

iOS緩存文件斷點機制

2011-11-16 15:08:30

AdobeAIRiOS應(yīng)用

2011-06-27 16:00:34

視頻教程Cocoa TouchiOS應(yīng)用

2018-10-25 15:13:23

APP脫殼工具
點贊
收藏

51CTO技術(shù)棧公眾號