void __fastcall TForm1::Mtext_File(UnicodeString file_Name, TListBox *lBox,UnicodeString new_File)
{
UnicodeString result,temp_File;
ofstream n_File;
wchar_t *buff;
int i,handle,size;
temp_File=file_Name;
handle=FileOpen(temp_File.w_str(),fmOpenRead);
size=FileSeek(handle,0,2);
if(size==-1)
{
result="Error! Can't open file - "+temp_File;
ShowMessage(result);
}
else
{
FileSeek(handle,0,0);
buff=new wchar_t[size+1];
FileRead(handle,buff,size);
FileClose(handle);
result=buff;
delete buff;
lBox->Items->Add(result);
n_File.open(new_File.w_str());
n_File<<result.w_str();
n_File.close();
}
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Mtext_File("readme.txt",TForm1::ListBox1,"new_question.txt");
}
Brak komentarzy:
Prześlij komentarz