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


相关文章:

  • 2022-12-23
  • 2021-11-30
  • 2021-12-10
  • 2021-06-27
  • 2022-12-23
  • 2021-05-19
  • 2021-07-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案