檔案操作類的一些方法

2021-05-25 15:43:57 字數 1850 閱讀 3371

binaryreader類——從檔案流中讀取二進位制檔案

建構函式:binaryreader() 

過載,例項化乙個

binaryreader物件

方法:

close(),關閉當前

reader

和潛在的流

dispose(),釋放被

binaryreader

使用的未託管的資源,並選擇性的釋放託管資源

equals(),判斷指定物件是否和當前物件相等

fillbuffer(),用乙個從流中讀取的制定數量的位元組來填充內在緩衝區

finalize(), 在物件被**機制**資源之前,允許該物件嘗試釋放資源和執行其他清除操作

gethashcode(), 作為乙個

hash

函式為制定型別提供服務

gettype(), 得到當前例項的型別

memberwiseclone(), 為當前物件建立乙個淺拷貝

peekchar(), 返回下乙個可用的字元,並且不前景字元或位元組的位置

read(), 過載,從潛在的流中讀取字元,並且移動當前流的位置

屬性:basestream  

訪問潛在二進位製流

binarywriter類——將二進位製流寫入檔案中

與reader

類相似,方法稍微少了點。

用法:

一般都是先用filestream

定義乙個檔案流物件,然後再用

binaryreader

或binarywriter

對檔案進行讀寫。

directory類

exposes static methods for creating, moving, and enumerating through directories and subdirectories. this class cannot be inherited.

提供一些靜態方法來建立,移動 並且列舉目錄和子目錄。類不能夠被繼承。

file類

provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of  filestream  objects.

提供一系列靜態方法來建立、拷貝、刪除、移動和開啟建立的檔案,並且幫助檔案流物件的建立。

directoryinfo類

exposes instance methods for creating, moving, and enumerating through directories and subdirectories. this class cannot be inherited.

提供例項化方法來建立,移動,列舉目錄和子目錄,該類不能被繼承。

基本的方法:

create(),

createsubdirectory(),

move(),

getdirectories(),

getfiles(),

fileinfo類

provides instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of  filestream  objects. this class cannot be inherited .

基本的方法:

create(),

delete(),

copy(),

open(),

move()

math 類的一些方法

system.out.println math.pi system.out.println math.abs 10 取絕對值 system.out.println math.ceil 12.3 向上取整 system.out.println math.ceil 12.99 system.out.pr...

操作iframe的一些方法

父頁面操作iframe裡的內容 oinput.onclick function iframe操作父頁面裡的內容 window.parent.document.getelementbyid box window.top.document.getelementbyid box window.onload...

檔案操作的一些感想

這幾日一直在做一些基於c的檔案操作的工作,遇到了一些有意思的錯誤,特此記載下來,以便以後查閱!問題一 如何向檔案中寫入回車換行 方法一 char ch 2 ch 0 13 ch 1 10 fs.write ch,sizeof char 2 fs 是fstream型別 方法二 fs.write r n...