Home > Back-end >  How do I can return the correct path???????
How do I can return the correct path???????

Time:09-20

Problems of the code is as follows:
=======================================================
Procedure TForm5. SpeedButton13Click (Sender: TObject);
Var
MBWJ HYWJ: string;
Data: the String;
The begin
IF not FileExists (Edit10. Text) then//check whether restore database object files exist
The begin
Showmessage (' please select a backup file to restore ');
exit;
end;
If application. MessageBox (' confirmation to restore it, it is suggested that the current backup data first? ', 'prompt', mb_okcancel)=idok then
The begin

MBWJ:=Edit10. Text;//used to restore the database backup file path
HYWJ:=Edit11. Text;//the path of the current database system
TRY
//======================
FORM6. Timer1. Enabled:=true;
FORM6. Label1. Caption:='recovering data, please wait......'.
FORM6. DATABACKUP:=2;
FORM6. Update;
//==========================
Used by CopyFile (PChar (MBWJ), PChar (HYWJ), FALSE);//the current database backup file overwritten before
//===============
FORM6. Show;
FORM6. Update;
FORM6. BACKUPPBAR (MBWJ HYWJ);
//==================
Showmessage (' recovery success! System after 5 seconds to enter! ');
WinExec (' restart. Exe, 1);
Application.Terminate;
Except,
Showmessage (' recover data failed, please try again! ');
end;
end;
end;
//========================================================

The above code before running path is forms: [C: \ Users \ AAAAAA \ BBBBBB \ DATA \ XXXXXX DAT] (XXXXXX. DAT is a database file),

But when you run the backup database, path unexpectedly became [C: \ Users \ AAAAAA \ BBBBBB \ \ DATA backup directory \ XXXXXX DAT],

Now ask: how to return to the path of the backup before?

CodePudding user response:

Single step debugging, pay attention to is caused by relative paths,

CodePudding user response:

Please post
FORM6. Update;
FORM6. BACKUPPBAR (MBWJ HYWJ);
Code,
  • Related