Bonsoir à tous
Lorsque CopyFile() échoue, elle retourne False. Mais à propos de quel fichier : source, ou destination ?
Un exemple de code :
Erreur retournée :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 procedure TForm1.Btn_1Click(Sender: TObject); Var Source, Dest : string; Err : integer; begin Form1.StatusBar.Panels[0].Text := ''; Form1.StatusBar.Update; Source := 'Project1.res'; Dest := 'Project1/bak'; // Volontaire : Dest est un nom de fichier incorrect if CopyFile( PChar(Source), PChar(Dest), False) = False then begin Err := GetLastError; Form1.StatusBar.Panels[0].Text := 'ERREUR NUMERO : ' + IntToStr(Err); Form1.StatusBar.Update; Exit; end; Form1.StatusBar.Panels[0].Text := 'PAS D''ERREUR'; Form1.StatusBar.Update; end;
Oui, mais quel est le fichier qui a provoqué cette erreur ? Source, ou Destination ? Ici : https://msdn.microsoft.com/en-us/library/aa910674.aspx , je ne vois pas la réponse.
Partager