C 讀取txt格式檔案內容

2022-01-26 06:40:42 字數 830 閱讀 7911

讀取檔案內容有三種方式

a.全部讀取到字串變數中

b.一次讀取一行

c.全部讀取到字串陣列中,每個陣列元素儲存一行文字

string text = system.io.file.readalltext(@"

d:\test.txt");

system.console.writeline(

"contents of writetext.txt =

", text);

view code

int counter = 0

; string

line;

system.io.streamreader file =

new system.io.streamreader(@"

d:\test.txt

");

while((line = file.readline()) != null

)

file.close();

system.console.writeline(

"there were lines.

", counter);

view code

string lines = system.io.file.readalllines(@"

d:\test.txt");

system.console.writeline(

"txt = ");

foreach (string line in

lines)

view code

C 讀取csv格式檔案

方法1 用乙個system.web.ui.htmlcontrols.htmlinputfile去handle檔案選取 以下是button click event中的code,用來執行當檔案選取了之後讀取檔案的內容 方法2 當成sql的資料表來讀取 select into theimporttable...

讀取clob格式檔案

create table a content clob select content from a 顯示的內容為cotent中的部分內容和亂碼,因為a是clob型別,不能直接從select的結果中顯示出來,需要借用oracle系統的包dbms lob來處理,才能正確顯示出來content的內容。se...

Unity裡面讀取TXT格式檔案並載入裡面的的資料

unity裡面讀取txt格式檔案並載入裡面的的資料 using unityengine using system.collections using system.collections.generic using unityengine.ui using system.text.regularex...