CopyFile/fi
English · Français · Suomi · Русский
Tiedoston kopiointi
Lazaruksen Käännösyksikkö fileutil (jossa on UTF-8 korvaukset FPC RTL koodille ja lisänä tiedoston/hakemiston käsittelyrutiineja)
// flags for copy
type
TCopyFileFlag = (
cffOverwriteFile,
cffCreateDestDirectory,
cffPreserveTime
);
TCopyFileFlags = set of TCopyFileFlag;
function CopyFile(const SrcFilename, DestFilename: string): boolean;
function CopyFile(const SrcFilename, DestFilename: string; PreserveTime: boolean): boolean;
function CopyFile(const SrcFilename, DestFilename: string; Flags: TCopyFileFlags=[cffOverwriteFile]): boolean;Funktio copyfile kopio tiedoston kohdetiedoston sijaintiin. Valinnaisesti se säilyttää tiedoston aikaleiman.
Funktio palauttaa boolean arvon true, jos se onnistui ja falsen jos tapahtui virhe.
Note: Jos halutaan käyttää tätä funktiota komentoriviohjelmissa niin pitää lisätä projektin vaatimuksiin LazUtils, jolloin ei tuoda mukaan koko LCL-kirjastoa
Windows esimerkki
uses
...
fileutil
...
CopyFile('c:\autoexec.bat','c:\windows\temp\autoexec.bat.backup');Lazarus esimerkki
Seuraavia komponentteja tai funktioita käytetään tässä esimerkissä:
procedure TForm1.Button1Click(Sender: TObject);
var
ok:boolean;
begin
ok := false;
if OpenDialog1.Execute then
if SaveDialog1.Execute then
ok := CopyFile(OpenDialog1.FileName, SaveDialog1.FileName);
if ok then MessageDlg('File '+OpenDialog1.FileName+' successfully copied to '+
SaveDialog1.FileName,mtInformation,[mbOk],0)
else MessageDlg('Copying failed',mtWarning,[mbOk],0);
end;From the Free Pascal wiki, page "CopyFile/fi", as it stood on 2019-09-08 after a change by Djzepi, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.


