I am trying to back up a file using an open dialog and close dialog to specify the source and destination. The only part I really need is how to actually save it. Any ideas?
Here is my code:
------------------------------------
There's no place like 127.0.0.1
------------------------------------
Here is my code:
Code:
procedure TfrmMain.cmdBackupClick(Sender: TObject);
var
openDialog : TOpenDialog; // Open dialog variable
saveDialog : TSaveDialog; // Save dialog variable
OpenPath, SavePath : String; // Save file from and to
begin
// Create the open dialog object - assign to our open dialog variable
openDialog := TOpenDialog.Create(self);
// Give the dialog a title
openDialog.Title := 'Select the Quickbooks Company File to backup';
// Set up the starting directory to be the current one
openDialog.InitialDir := GetCurrentDir;
// Only allow existing files to be selected
openDialog.Options := [ofFileMustExist];
// Allow only .dpr and .pas files to be selected
openDialog.Filter :=
'Quickbooks Company File|*.qbw';
// Select pascal files as the starting filter type
openDialog.FilterIndex := 1;
// Display the open file dialog
if openDialog.Execute
then OpenPath := openDialog.FileName
else
begin
ShowMessage('Backup cancelled');
exit;
end;
// Free up the dialog
openDialog.Free;
//**************** --> Save File
// Create the save dialog object - assign to our save dialog variable
saveDialog := TSaveDialog.Create(self);
// Give the dialog a title
saveDialog.Title := 'Select where to save the Quickbooks Company File';
// Set up the starting directory to be the current one
saveDialog.InitialDir := GetCurrentDir;
// Allow only .txt and .doc file types to be saved
saveDialog.Filter := 'Quickbooks Company File|*.qbw';
// Set the default extension
saveDialog.DefaultExt := 'qbw';
// Select text files as the starting filter type
saveDialog.FilterIndex := 1;
// Display the open file dialog
if saveDialog.Execute
then SavePath := saveDialog.FileName
else
begin
ShowMessage('Backup cancelled');
exit;
end;
// Free up the dialog
saveDialog.Free;
end;
------------------------------------
There's no place like 127.0.0.1
------------------------------------