Autor Beitrag
jackie05
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 357



BeitragVerfasst: Do 03.04.08 06:06 
Hallo nochmal,
ich habe ein kleines problem mit der Indy(IdHTTP1) Komponent und zwar, wenn ich über diese Komponent eine Datei downloade, dann nach ca. 10% erhalte ich eine fehlermeldung.
Moderiert von user profile iconNarses: Bild als Anhang hochgeladen

Hier wird dann der Fehler gezeigt:
ausblenden Delphi-Quelltext
1:
fs := TFileStream.Create(filename, fmCreate);					


Hier ist mal der Download-Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm2.Timer1Timer(Sender: TObject);
begin
  try
    fs := TFileStream.Create(filename, fmCreate);
    IdHTTP1.Get(URL, fs);
    fs.free;
    Timer1.Enabled := false;
    Application.MessageBox('Der Download ist abgeschlossen.''Hinweis!', MB_OK);
    Button2.Caption := 'OK';
    Button1.Enabled := true;
    Button2.Enabled := true;
  except
    Timer1.Enabled := false;
    Application.MessageBox('Die Datei konnte nicht heruntergeladen werden!''Fehler!', MB_OK);
    Button2.Caption := 'OK';
    Button1.Enabled := true;
    Button2.Enabled := true;
    fs.Free;
  end;
end;


kann es vieleicht daran liegen das ich den Code in einem Timer drin habe?

Ich bedanke mich schonmal im Voraus.

[EDIT] also es lag doch an den Timer, ich habe den Code in einem Button rein kopiert und nun funktioniert es.

MfG
Einloggen, um Attachments anzusehen!
MrKnogge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

Win XP, Win 7
Delphi 7 Prof, Delphi 2005 PE, C# (VS 2008)
BeitragVerfasst: Mo 14.04.08 15:21 
Hallo,

wie groß ist denn die Datei und in welchem Intervall wird die Funktion aufgerufen?
Hast du den Code mal ohne Timer getestet?

Grüße

_________________
MfG MrKnogge
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 14.04.08 16:24 
Trotz deines Edits will ich dir noch die genaue Fehlerquelle nennen:
Du deaktivierst zwar den Timer, damit der Download nicht nochmal gestartet wird, jedoch erst nachdem der Download fertig ist. Deshalb wird der Download ein weiteres Mal gestartet, und kann die Datei nicht öffnen, da du sie schon geöffnet hast. Daher der Absturz.

Lösung: Timer vor dem Download deaktivieren.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mo 14.04.08 16:57 
*grübel*
Ich hab grad ein deja-vu.
Hatten wir nicht vor kurzem eine Diskussion, in der gesagt wurde, dass erst ein neues Timer Ereignis ausgelöst wird, wenn das "alte" abgearbeitet wird? Also, dass sich diese Events nicht "stauen".

Ich versteh nun grad den Unterschied zu diesem Beispiel nicht so ganz.
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Mo 14.04.08 17:09 
Das nächste wird erst abgearbeitet, wenn die Nachrichtenschleife wieder frei ist, also mal ein Application.ProcessMessages vorkam.
Da er aber den Fortschritt anzeigt, und zur aktualisierung der Darstellunge ein Aufruf von Application.ProcessMessages vonnöten ist, hab ich jetzt einfach mal angenommen, dass das so ist.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.