Hi!
Ich schreibe momentan einen Downloadmanager für mehrere Dateien.
Das runterladen funktioniert auch ganz gut.
Es gibt einen Großes Thread "LoadDownloads". Der die Dateien aus der Downloadliste, welche in einer XML Datei hinterlegt sind sofern sie noch nicht runtergeladen wurden runterlädt. (Pause/Abbrechen bau ich später ein).
Er erstellt also für jeden Download einen Extra Thread und startet sobald alle download Threads gestartet sind folgende 2 Threads:
UpdateStatus
UpdateDLSpeed.
Auch das klappt alles >einwandfrei<
Doch die heruntergeladene Datei ist genau etwa 1/100stel kleiner. (siehe screenshot)
Kann das daran liegen?
Datei liegt auf einen Server mit dem OS Linux ?
Aber jetz kommt es... im code steht erst wenn BytesOnDisk == BytesOnServer ist soll er die Datei ausm Temp Verzeichnis ins richtige kopieren.
Nach etwa 5 Minuten warte Zeit bei Prozent 99 macht er das auch. Datei ist aber dennoch kleiner als Auf dem Server (Byte vergleich).
1. Weiß ich nicht wie das Möglich sein soll und 2. weiß ich nicht wie ich dieses Problem beheben / umgehen kann.
Anbei ein kleiner Codesausschnitt.
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: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64:
| private void PercenNowVoid() {
int indexes = MyDownloads.RowCount-1; for (int x = 0; x < indexes; x++) {
string filename = MyDownloads.Rows[x].Cells[1].Value.ToString(); long filesize = Convert.ToInt64((MyDownloads.Rows[x].Cells[3].Value.ToString()).Replace("Bytes",""));
if (MyDownloads.Rows[x].Cells[4].Value != "Fertig." && MyDownloads.Rows[x].Cells[4].Value != "Kopiere...") { if (File.Exists(@"C:\NFloader\TEMP\" + filename + "")) { FileInfo F = new FileInfo(@"C:\NFloader\TEMP\" + filename + ""); decimal Prozent = (F.Length * 100) / filesize; int II = Convert.ToInt32(Math.Round(Prozent)); if (MyDownloads.Rows[x] != null) {
if (Prozent < 100) { MyDownloads.Rows[x].DefaultCellStyle.BackColor = System.Drawing.Color.Orange; MyDownloads.Rows[x].Cells[4].Value = Prozent.ToString(); label3.ExecuteThreadSafe(() => label3.Text = F.Length.ToString() + "/" + filesize); } else {
if (F.Length == filesize) {
MyDownloads.Rows[x].Cells[4].Value = "Kopiere...";
if (!File.Exists(@"C:\NFloader\" + filename)) File.Copy(@"C:\NFloader\TEMP\" + filename + "", @"C:\NFloader\" + filename,true); else { if (MyDownloads.Rows[x].Cells[4].Value != "Fertig.") { MyDownloads.Rows[x].DefaultCellStyle.BackColor = System.Drawing.Color.Green; MyDownloads.Rows[x].Cells[4].Value = "Fertig."; } } } else { MyDownloads.Rows[x].DefaultCellStyle.BackColor = System.Drawing.Color.Blue; MyDownloads.Rows[x].Cells[4].Value = "Validiere...";
} }
} } } } Thread T1 = new Thread(new ThreadStart(PercenNowVoid)); T1.Start(); } |