C 檔案IO操作

2022-04-05 01:21:31 字數 1188 閱讀 2299

3. 檔案

a) 檔案基本操作

ø public static filestream create(string)---給定檔案路徑名,建立檔案,並返回乙個filestream流物件。

ø public static streamwriter createtext(string)---給定檔案路徑名,以文字的方式建立檔案,並返回乙個streamwriter流物件。

ø public static void copy(string,string)---給定源路徑名和目錄路徑名,考貝檔案。

ø public static void move(string,string)---給定源路徑名和目錄路徑名,移支檔案。

ø public static void delete(string)---給定源路徑名和目錄路徑名,刪除檔案。

ø public static void exists(string)---給定源路徑名和目錄路徑名,判斷檔案是否存在。

b)獲取和設定檔案資訊

ø public static fileattributes getattributes(string)------給定源路徑名,獲取檔案的屬性集。

ø public static datetime getcreationtime(string)---給定檔案路徑名,獲取檔案建立賓日期和時間。

ø public static datetime getlastaccesstime(string)---給定檔案路徑名,獲得檔案最近一次被訪問的日期和時間。

ø public static datetime getlastwritetime(string)---給定檔案路徑名,獲得檔案最近一次被修改的日期和時間。

ø public static void setattributes(string,fileattributes)---給定檔案路徑名,設定檔案屬性集。

ø public static void setcreationtime(string,datetime)---給定檔案路徑名,設定檔案建立的日期和時間。

ø public static void setlastaccesstime(string,datetime)----給定檔案路徑名,設定檔案最近一次被訪問的日期和時間。

ø public static void setlastwritetime(string,datetime)---給定檔案路徑名,設定檔案最後一次被修改的日期和時間。

C語言檔案IO操作(標準IO)

函式 file fopen const char path,const char mode 引數1 將要開啟的檔案路徑 引數2 開啟檔案的方式 1.r 唯讀的方式開啟 2.w 若檔案不存在則建立檔案,若存在此檔案則清空檔案內容並打卡 3.a 若檔案不存在則建立檔案,若存在則在末尾追加 不會清空原檔案...

C語言 檔案I O操作

c語言讀寫檔案的步驟一般是 建立或開啟檔案 讀或寫檔案 關閉檔案 當然讀或寫的過程中還可以通過操作當前檔案偏移量來控制讀寫位置。下面分別介紹這些函式 標頭檔案 include 此標頭檔案定義了以下oflag o rdonly 唯讀0 o wronly 只寫1 o rdwr 讀寫2 上面三個oflag...

檔案IO操作

在對乙個檔案或者裝置進行讀寫之前,都需要先開啟,以獲得該檔案或者裝置的操作指標,也就是檔案描述符。有了檔案描述符,後續就可以進行讀取,修改操作了。標頭檔案函式宣告 int open const char pathname,int flags,mode t mode 返回值成功 返回檔案描述符 失敗 ...