Autor Beitrag
Xadron
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

XP
C++, D7, HTML
BeitragVerfasst: Fr 13.04.07 08:24 
Wie kann ich ganze Ordner mit inhalt kopieren?

ausblenden Quelltext
1:
 xcopy(.\hier-mein-ganzer-ordner\, C:\test\);					
?

_________________
|x-32:88x+39-3|+3:21=47-4x
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 13.04.07 08:36 

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Xadron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

XP
C++, D7, HTML
BeitragVerfasst: Fr 13.04.07 10:18 
Ich benutze dazu jetzt das:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
function DoFileWork(aOperation: FILEOP_FLAGS; aFrom, aTo: AnsiString;
    Flags: FILEOP_FLAGS): Integer;
var
  FromPath, ToPath: AnsiString;
  SHFileOpStruct: TSHFileOpStruct;
begin
  FromPath := aFrom + #0#0;
  ToPath := aTo + #0#0;
  with SHFileOpStruct do
  begin
    Wnd := 0;
    wFunc := aOperation;
    pFrom := PAnsiChar('.\inhalt\');
    if ToPath <> '' then
    begin
      pTo := PAnsiChar('D:\---\test\')
    end else begin // target available
      pTo := nil;
    end// target not available
    fFlags := Flags;
  end// structure
  Result := SHFileOperationA(SHFileOpStruct);
end;


Und zum Aufrufen:

ausblenden Delphi-Quelltext
1:
DoFileWork(Self.Handle, FO_COPY, strlFiles, nil, FOF_NOCONFIRMATION);					


Doch er meint:

[highlight][Fehler] Unit1.pas(55): Inkompatible Typen: 'String' und 'Integer'
[Fehler] Unit1.pas(55): Inkompatible Typen: 'Word' und 'Pointer'[/highlight]

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt

_________________
|x-32:88x+39-3|+3:21=47-4x
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 13.04.07 11:46 
Ganz schön schwer Text zu kopieren :wink:
ausblenden Delphi-Quelltext
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:
27:
28:
function DoFileWork(aOperation: FILEOP_FLAGS; aFrom, aTo: AnsiString;
    Flags: FILEOP_FLAGS): Integer;
var
  FromPath, ToPath: AnsiString;
  SHFileOpStruct: TSHFileOpStruct;
begin
  FromPath := aFrom + #0#0;
  ToPath := aTo + #0#0;
  with SHFileOpStruct do
  begin
    Wnd := 0;
    wFunc := aOperation;
    pFrom := PAnsiChar(FromPath);
    if ToPath <> '' then
    begin  
      pTo := PAnsiChar(ToPath)
    end else begin // target available  
      pTo := nil;
    end// target not available
    fFlags := Flags;
  end// structure
  Result := SHFileOperationA(SHFileOpStruct);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  DoFileWork(FO_COPY, 'C:\Von''C:\Nach'0);
end;

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Xadron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

XP
C++, D7, HTML
BeitragVerfasst: Fr 13.04.07 14:25 
Ja ok geht auch eigendlich, aber ich möchte Ordner mit inhalt kopieren, was er nicht tut.

C:\test\ kopiert er also nicht und außerdem müss der "kopier hin ordner" existieren, da er
ihn nicht automatisch erstellt.

_________________
|x-32:88x+39-3|+3:21=47-4x
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Fr 13.04.07 14:41 
Dann such doch einfach, wie man einen Ordner erstellt und schreib das auch noch in die Prozedur. :wink:

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 13.04.07 15:05 
aFrom ist der exestierende Ordner aTo wird erstellt.
Was soll daran nicht funktionieren, dann liegt es bestimmt wieder an deinen Pfaden.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Xadron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

XP
C++, D7, HTML
BeitragVerfasst: Fr 13.04.07 15:07 
Für alle 30 Ordner einzeln?
Kann man nicht einfach einen Ordner wählen und alles was da drinn ist in einen Ordner machen und wenn halt 20 Unterordner noch nicht existieren, werden die automatisch erstellt?
Kann man nicht irgendwie C++ Funktionen wie:
ausblenden Quelltext
1:
xcopy (.\\dateien\\mozilla  c:\\Progra~1\\ /c/e");					

in delphi einbinden?

_________________
|x-32:88x+39-3|+3:21=47-4x
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 13.04.07 15:14 
Was Denkst Du was der Code macht !
Wenns Bei Dir nicht hinhaut dann liegt es an Dir, bei Mir klappt das einwandfrei.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19312
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 13.04.07 15:16 
Du benutzt relative Pfade... ;-) Das geht halt schief, wen wunderts.
Du musst schon, wenn du das Exe-Verzeichnis meinst, dieses mit ExtractFilePath(ParamStr(0)) in demn Pfad dazuschreiben statt es mit .\ zu versuchen ;-).
Xadron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

XP
C++, D7, HTML
BeitragVerfasst: Fr 13.04.07 17:16 
Danke erstmal.
Kannst du mir vieleicht noch ein Tipp geben, wo ich das hin bzw mit was ersetzen muss ?

nochmal der code von black~ :

ausblenden Delphi-Quelltext
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:
27:
28:
function DoFileWork(aOperation: FILEOP_FLAGS; aFrom, aTo: AnsiString;
    Flags: FILEOP_FLAGS): Integer;
var
  FromPath, ToPath: AnsiString;
  SHFileOpStruct: TSHFileOpStruct;
begin
  FromPath := aFrom + #0#0;
  ToPath := aTo + #0#0;
  with SHFileOpStruct do
  begin
    Wnd := 0;
    wFunc := aOperation;
    pFrom := PAnsiChar(FromPath);
    if ToPath <> '' then
    begin  
      pTo := PAnsiChar(ToPath)
    end else begin // target available  
      pTo := nil;
    end// target not available
    fFlags := Flags;
  end// structure
  Result := SHFileOperationA(SHFileOpStruct);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  DoFileWork(FO_COPY, 'C:\Von''C:\Nach'0);
end;


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt

_________________
|x-32:88x+39-3|+3:21=47-4x
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19312
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 13.04.07 17:47 
Ähh, das geht bei mir anstandslos... Auch mit x Unterordnern und Dateien drin.
Was ich meinte war, dass du sowas hattest:
user profile iconXadron hat folgendes geschrieben:
ausblenden Quelltext
1:
xcopy (.\\dateien\\mozilla  c:\\Progra~1\\ /c/e");					

Und ein Pfad .\dateien\mozilla geht nicht (bzw. eben manchmal schief), weil das kein absoluter Pfad ist.
Da musst du dann sowas machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  DoFileWork(FO_COPY, ExtractFilePath(ParamStr(0)) + '\Von''C:\Nach'0);
end;
Xadron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

XP
C++, D7, HTML
BeitragVerfasst: Fr 13.04.07 18:15 
Danke Danke

_________________
|x-32:88x+39-3|+3:21=47-4x