Autor Beitrag
Mulanacai
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 17

Win Xp
D7 Ent.
BeitragVerfasst: Di 08.02.05 14:33 
Hey Leute,

ich hab da ma ein Problem...

Ich möchte Dateien kopieren. Über eine zweite Form, soll der ganze Kopierverlauf angezeigt werden ( bei welcher Datei er ist, Progress Bar, usw...)

Hab das so geschrieben:

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:
//mitten in der Prozedur, die kopiert, löscht, usw.
//deviceAction = 1 heisst nur "kopiere!!!"

max := frm_main.o_list.ItemCount;

if deviceAction = 1 then begin
  frm_copy.Show;
  
  for i := 0 to max -1 do 
  begin
    filename := ExtractFileName(frm_main.o_list.Lines[i]);
    frm_copy.doFormShit(1, max, i, filename);  //setzt die Label.Captions der ganzen Infos

    NewFileName := devicePath + ExtractFileName(frm_main.o_list.Lines[i]);
    OldFile := TFileStream.Create(ExtractFileName(frm_main.o_list.Lines[i]), fmOpenRead);
      try
        NewFile := TFileStream.Create(NewFileName, fmCreate);
        try
          NewFile.CopyFrom(OldFile, OldFile.Size);
        finally
          FreeAndNil(NewFile);
        end;
      finally
        FreeAndNil(OldFile);
      end;
  end;
end;


Das Problem hierbei liegt darin, das die Form zwar angezeigt wird, die Inhalte, an denen man den Kopierstatus ja ablesen soll, erst erscheint, wenn das kopieren bereits zu Ende ist... Es "laggt" sozusagen...

Noch zu erwähnen wäre da, das auf einen USB Stick kopiert wird, was an sich ja ne Weile dauern kann.

Wäre vielleicht die WINAPI-Func CopyFile() schneller, als die Dateien alle über Streams zu kopieren? (Also nicht vom Kopiervorgang her schneller, aber schnell genug, damit das Prog die Form (!vollständig!) gleichzeitig zum kopieren angezeigt werden kann?

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconTino: Überflüssige Absätze entfernt.

_________________
A programmer is just a tool which converts coffeine into code!
st-matze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 138

Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
BeitragVerfasst: Di 08.02.05 14:41 
in deiner funktion doFormShit musst du die Repaint oder Refresh funktion der Labels aufrufen, damit die aktualisierung der Anzeige während des kopierens erfolgt.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 08.02.05 14:48 
oder application.processmessages
st-matze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 138

Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
BeitragVerfasst: Di 08.02.05 15:13 
application processmessages kann man auch verwenden. es ist sogar mit weniger aufwand einzubinden, allerdings benötigt es auch mehr zeit.

soltest du austesten was für deinen bedarf günstiger ist, da der unterschied teilweise extrem ist.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 08.02.05 15:43 
st-matze hat folgendes geschrieben:
allerdings benötigt es auch mehr zeit.

jo, rechenzeit ! und die ist bei application.processmessages nicht unbeträchtlich. deine version ist sicher die elegantere.
Mulanacai Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 17

Win Xp
D7 Ent.
BeitragVerfasst: Di 15.02.05 10:52 
Hey vielen Dank Leute,

cu

_________________
A programmer is just a tool which converts coffeine into code!