FileOperations (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example demonstrates the copying, moving and deleting of files provided by methods of TFile class.

Code

void __fastcall TForm1::operations(TObject *Sender)
{
	try
	{
	/* Copy file from source file path to destination file path */
	if (Sender == btnCopy)
		TFile::Copy(edSourcePath->Text, edDestinationPath->Text);

	/* Move file from source file path to destination file path */
	if (Sender == btnMove)
		TFile::Move(edSourcePath->Text, edDestinationPath->Text);

	/* Delete file from source file path */
	if (Sender == btnDelete)
		TFile::Delete(edSourcePath->Text);
	}
	catch(...)
	{
		MessageDlg("Incorrect path", mtError, TMsgDlgButtons() << mbOK, 0);
		return;
	}
}
//---------------------------------------------------------------------------

Uses

Personal tools
Assistance