#import
"rootviewcontroller.h"
@inte***ce
rootviewcontroller()
@end
@implementation
rootviewcontroller
- (void
)viewdidload
else //
寫入內容
nsstring
*content =
@"這是乙個新的章節";
[content
writetofile
: filepath
atomically
:yes
encoding
:nsutf8stringencoding
error
:nil];
//讀出來
nsstring
*readresult = [
nsstring
stringwithcontentsoffile
:filepath
encoding
:nsutf8stringencoding
error
:nil];
nslog
(@"%@"
,readresult); //
檔案的複製(在
documents
資料夾裡面複製乙份)
nsstring
*copyfilepath = [doupath
: @"
金瓶梅複製版
.txt"];
[manager
copyitematpath
:filepath
topath
:copyfilepath
error
:nil];
//檔案的移動(將金瓶梅
.txt
移動到library
資料夾中) //
獲取library
資料夾路徑
nsstring
*librarypath = [
nssearchpathfordirectoriesindomains
(nslibrarydirectory
,nsutf8stringencoding
, yes
)lastobject];
nsstring
*movefilepath = [librarypath:@"
金瓶梅.txt"];
[manager
moveitematpath
:filepath
topath
:movefilepath
error
:nil];
//檔案的刪除(將金瓶梅複製版刪除) if
([manager
fileexistsatpath
:copyfilepath]) //
檢視資料夾下的所有檔案
nsarray
*array = [manager
contentsofdirectoryatpath
:doupath
error
:nil];
nslog
(@"%ld"
,[array
count
]);
nslog
(@"%@"
,array); //
總結 //對檔案的操作實際上是檔案路徑的操作,需要借助檔案管理者
nsfilemanager //
讀寫檔案只能是
nsstring,nsarray,nsdictionary,nsdata,
自定義類是無法直接寫入檔案的 //
目前開發過程中主流的檔案處理
nsuserdefaults
,資料庫,
coredata //
要把乙個自定義的類寫入檔案,需要借助歸檔操作,讀出來是反歸檔
// do any additional setup after loading the view. }
- (void
)didreceivememorywarning
@end
python讀寫本地檔案
這篇文章主要介紹python讀寫本地檔案的操作方法和詳細解析 f open readfile name.txt r connect f.read print connect file close 檔案讀取過後關閉檔案注釋 上面的三行 第一行的詳細解析為 用open 函式直接開啟括號中第一項的那個文字...
linux下讀寫本地配置檔案
以windows下ini配置檔案為模板。檔案內容舉例,screen attr real width 1280 real height 720 virtual width 1280 virtual height 720 disp resolution值參考 1 720p,2 1080p,3 1440 ...
本地檔案讀寫
coding utf 8 import os 本地檔案讀寫操作的大致流程 1 開啟檔案 需要指定檔案的開啟方式,比如可讀 可寫等 2 對檔案進行讀 寫操作 3 關閉檔案 檔案的寫入資料操作 第乙個值text.txt 要開啟檔案所在的路徑,當前寫的是相對路徑,預設在當前目錄下 進行查詢 也可以指定為絕...