Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Datei kopieren bitte um konkretes beispiel (https://www.delphipraxis.net/28888-datei-kopieren-bitte-um-konkretes-beispiel.html)

Tzuxy 31. Aug 2004 20:12


Datei kopieren bitte um konkretes beispiel
 
Bei mir klappts einach nicht mit dem quelltext...

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, shellapi, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
 function DoFileWork( 
  aWnd: HWND; aOperation: UINT; aFrom, aTo: TStrings; Flags: FILEOP_FLAGS): Integer;
var
  I: Integer;
  FromPath, ToPath: string;
  SHFileOpStruct: TSHFileOpStruct;
begin
  FromPath := '';
  for I := 0 to aFrom.Count - 1 do
    FromPath := FromPath + aFrom.Strings[I] + #0;
  FromPath := FromPath + #0;

  if Assigned(aTo) then
  begin
    ToPath := '';
    for I := 0 to aTo.Count - 1 do
      ToPath := ToPath + aTo.Strings[I] + #0;
    ToPath := ToPath + #0;
    if aTo.Count > 0 then
      Flags := Flags or FOF_MULTIDESTFILES;
  end;

  with SHFileOpStruct do
  begin
    Wnd := aWnd;
    wFunc := aOperation;
    pFrom := PChar(FromPath);
    if Assigned(aTo) then
    begin
      pTo := PChar(ToPath)
    end else begin // target available
      pTo := nil;
    end; // target not available
    fFlags := aFlags;//undeclared identifier
  end; // structure
  Result := SHFileOperation(SHFileOpStruct);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
DoFileWork(Self.Handle, FO_DELETE, strlFiles, nil, FOF_ALLOWUNDO);
end;

end.
Erster fehler:
undeclared identifier: 'aflags'

Zweiter Fehler:
undeclared identifier: 'strlFiles'

....

Kann mir bitte jemand einen Code für ein Beispiel geben.
Zum Beispiel von C:\text.exe nach c:\projekt\test.exe.
Also eine Datei kopieren.
Find leider dazu nichts im Forum


mfg Werner

MathiasSimmack 31. Aug 2004 20:19

Re: Datei kopieren bitte um konkretes beispiel
 
Zitat:

Zitat von Tzuxy
Erster fehler:
undeclared identifier: 'aflags'

Hey, da war doch mal was. Bei "AFlags" macht´s -klick-, und ich würde sagen, du lässt einfach mal das A weg, weil das wohl ein Tippfehler im Quellcode war.

Zitat:

Zweiter Fehler:
undeclared identifier: 'strlFiles'
Vermutlich eine globale String-Variable, die den Namen der Datei enthält. Ersetze sie doch einfach zum Test mal durch den richtigen Namen inkl. Pfad.

Auch wenn du ein Anfänger sein solltest: Delphi explodiert nicht (hoffe ich), wenn du einfach mal was ausprobierst. ;)

City Light 31. Aug 2004 20:27

Re: Datei kopieren bitte um konkretes beispiel
 
Hallo Tzuxy

Schau mal in der deiner Hilfedatei von Delphi rein
und such mal nach CopyFile um es auch gleich zu verstehen.

hier ein Beispiel
Delphi-Quellcode:
CopyFile('C:/test.exe','c:/test_copy.exe',True);
MFG
Tino

fiasko 31. Aug 2004 20:31

Re: Datei kopieren bitte um konkretes beispiel
 
Delphi-Quellcode:
DoFileWork(Self.Handle, FO_DELETE, strlFiles, nil, FOF_ALLOWUNDO);
Kopieren mittels löschen? :gruebel:


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:41 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz