Autor Beitrag
Kinimod8
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 24

Win XP Home
D3 Prof
BeitragVerfasst: Di 05.08.03 10:19 
Hallo,

wie kann ich einen Ordner kopieren?
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 05.08.03 10:46 
Hallo,

am besten benutzt du die Suche in: Delphi-Forum, Delphi-Library SHFILEOPERATION Funktion. Hier ein Beispiel:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Uses
  ShellAPI;

Function CopyFolder (aSource, aDest: String): Boolean;
Var
  FS: TSHFileopStruct;
Begin
  FillChar (FS, SizeOf (FS), 0);

  With FS Do
    Begin
      wFunc := FO_COPY;
      pFrom := PChar (aSource + #0);
      pTo := PChar (aDest + #0);
    End;

  CopyFolder := SHFileOperation (FS) = 0;
End;

Aufgerufen kann die Funktion wie folgt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
  If Not CopyFolder ('c:\Folder', 'z:\Folder2') Then
    { Fehler } ;
end;


Gruß
Tino
wurzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 75

Win 2000, Win XP
BDS 2006 (Delphi, Delphi .NET, C++)
BeitragVerfasst: Fr 23.02.07 20:46 
Wie kann ich der Funktion ne längere Zeichenkette entlocken? Also das Dateinamen länger sein können?

_________________
"Könntest du deinen Egotrip mal kurz unterbrechen? Es ist was wichtiges passiert." - "Wenn es irgendwas wichtigeres als mein Ego gibt, verlange ich, dass man es auf der Stelle verhaftet und erschießt."
del1312
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Fr 02.11.07 10:05 
wie kann man das so ändern, das vorhandene dateien und ordner überschrieben werden?
gispos
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 94

WIN 7
XE10, D2007
BeitragVerfasst: Fr 02.11.07 13:48 
user profile iconecspooky hat folgendes geschrieben:
wie kann man das so ändern, das vorhandene dateien und ordner überschrieben werden?

Du meinst wohl ohne das ein Dialog erscheint?
fFlags:= FOF_NOCONFIRMATION noch zu obiger Funktion hinzufügen.
Aber Du solltest Dir auch mal die Hilfe anschauen, denn da gibts noch ne Menge anderer
Flags, und Flags werden immer mit "or" kombiniert
zB. FOF_RENAMEONCOLLISION or FOF_NOCONFIRMATION or FOF_SILENT

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
typedef struct _SHFILEOPSTRUCT {
    HWND hwnd;
    UINT wFunc;
    LPCTSTR pFrom;
    LPCTSTR pTo;
    FILEOP_FLAGS fFlags;
    BOOL fAnyOperationsAborted;
    LPVOID hNameMappings;
    LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;


Gruß gispos

Moderiert von user profile iconNarses: C#-Tags hinzugefügt
del1312
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Fr 02.11.07 14:14 
vielen dank für den tipp. naja als so nen abfragefenster kommt eigentlich gar nicht erst. wenn ich mehrmals einfach kopiere dann legt er jedesmal die dateien so an:

datei.txt
datei(1).txt
datei(2).txt

usw. ich will einfach das die ohne fragen ersetzt werden.