码迷,mamicode.com
首页 > 编程语言 > 详细

c++builder 读写文件类

时间:2015-07-14 17:45:53      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

c++builder 读写文件类

TStreamReader、TStreamWriter
读取一行
http://docwiki.embarcadero.com/CodeExamples/XE8/en/StreamCharRdWr_%28C%2B%2B%29
void __fastcall TMainForm::btSaveClick(TObject *Sender)
{
    TStreamWriter* writer;
 
    /* Create a new stream writer directly. */
    writer = new TStreamWriter("local_file.txt",
        false, TEncoding::UTF8, 1024);
 
    /* Store the title and then the text. */
    writer->WriteLine(edtTitle->Text);
    writer->Write(mmText->Text);
 
    /* Close and Free the writer. */
    delete writer;
}
 
void __fastcall TMainForm::btLoadClick(TObject *Sender)
{
    TStreamReader* reader;
 
    /* Create a new stream writer directly. */
    reader = new TStreamReader("local_file.txt",
        TEncoding::UTF8);
 
    /* Read the title and then the actual text. */
    edtTitle->Text = reader->ReadLine();
    mmText->Text = reader->ReadToEnd();
 
    /* Close and Free the writer. */
    delete reader;
}

 

TStringReader、
TStringWriter


c++builder 读写文件类

标签:

原文地址:http://www.cnblogs.com/cb168/p/4645706.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!