Autor Beitrag
schitho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 288

XP Home SP2
D2005 Prof
BeitragVerfasst: Do 01.04.04 22:18 
Hi,

wieso funktioniert nachfolgender Code nicht?

Die Prozedure sollte alle Dateien aus einem Verzeichnis in ein anderes kopieren und dabei auch noch den Namen leicht verändern (anfügen von (*1*), (*2*), etc.).


ausblenden volle Höhe 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:
29:
30:
31:
32:
procedure TForm1.BtnStartClick(Sender: TObject);
  var
  sr: TSearchRec;
  FileAttrs: Integer;
  LW, Pfad, DateiName, Ext : String;
  Counter : Integer;
  zieldatei : string;
  vondatei: string;
  erg: boolean;

begin
  counter:=0;
  if FindFirst(EVonDir.Text+'*.*', faAnyFile  , sr) = 0 then
  begin
    repeat
      PathExtractElements(sr.Name,LW,Pfad,DateiName,Ext);
      if (Ext <>'.') and (Ext<>'.dat') and (Ext <>'..') then
      begin
        counter:=counter+1;
        ZielDatei:=EZielDir.Text+DateiName+'(*'+ IntToStr(counter)+'*)'+Ext;
        VonDatei:=EVonDir.Text+sr.Name;
        showMessage(VonDatei);
        if not CopyFile(PChar(VonDatei),PChar(ZielDatei),true)=true then
        begin
          showMessage ('Konnte ' + VonDatei + ' nicht kopieren nach ' + ZielDatei);
        end

      end;
    until FindNext(sr) <> 0;
    FindClose(sr);
  end;
end;


Die Datei wird zwar gefunden, allerdings wird die Datei nicht kopiert, obwohl das Verzeichnis vorhanden ist.

Irgendwo ist der Hund begraben. Aber wo?

Danke

Gruß
Thomas

_________________
(Sorry! Leider ewiger Delphi-Neuling)
schitho Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 288

XP Home SP2
D2005 Prof
BeitragVerfasst: Do 01.04.04 23:43 
Hab den Fehler gefunden. Es lag an den * im Dateinamen. :oops:

Gruß
Thomas

_________________
(Sorry! Leider ewiger Delphi-Neuling)