ERLEDIGT
JA
JA
ANTWORTEN
4
4
ZUGRIFFE
651
651
EMPFEHLEN
-
Hallo Leute,
ich möchte gerne eine Datei von einem Http Server runterladen, was auch tadelos funktioniert. Nur ich möchte gerne die Größe der Datei vor dem Download ermitteln. Ich habe schon bei google und hier auch gesucht, nur leider nichts entsprechendes gefunden.
Vielen Dank im vorraus und viele Grüße
FirdulinGeändert von Fridulin (05.11.05 um 02:20 Uhr)
-
06.11.05 18:22 #2
- Registriert seit
- Aug 2001
- Ort
- Österreich, Stmk, Graz
- Beiträge
- 2.783
Hi.
Was benutzt zum Runterladen?
Die HttpWebResponse Klasse hat eine Eigenschaft namens ContentLength.
MfG,
AlexWith the first link the chain is forged. The first speech censored, the first thought forbidden, the first freedom denied, chains us all irrevocably.
Aaron Satie
Legends... are the spice of the universe, Mr. Data, because they have a way of sometimes coming true.
Captain Jean-Luc Picard, Stardate ~41294.5
Tutorials.de chattet. Hier gibts auch .net Support ^^
Klickt auf chattet und nutzt den Webchat, oder verbindet euch zu irc.tutorials.de - Channel #Tutorials.de
(moo)blog furred.net // SiteInfo für WP7 // Pastebin für WP7 // BlogEngine.net Extensions
-
Hi,
danke für deine Antwort. Ich mache das über .NetClient und StreamReader.
mein code:
Code :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
System.Net.WebClient MyClient = new System.Net.WebClient(); System.IO.Stream MyStream = MyClient.OpenRead(adresse); System.IO.StreamReader MyStreamReader = new System.IO.StreamReader(MyStream); //pfad erstellen string downloadpfad = Application.StartupPath + "\\Downloads"; if (!Directory.Exists(downloadpfad)) { Directory.CreateDirectory(downloadpfad); } using (BinaryWriter writer = new BinaryWriter( File.Create( Path.Combine(downloadpfad, dateiname)))) { double a = 0; double empfanngen = 0; double dat_empfanngen = 0; double zeit = 0; double geswalt = 0; double bit = 0; while (true) { byte[] buffer = new byte[1024]; int read = MyStream.Read(buffer, 0, 1024); writer.Write(buffer, 0, read); dat_empfanngen += read; a=a+1; if (read == 0) break; }
Grüße
Fridulin
-
06.11.05 20:32 #4
- Registriert seit
- Aug 2001
- Ort
- Österreich, Stmk, Graz
- Beiträge
- 2.783
Nach OpenRead kannst MyClient.ResponseHeaders["Content-Length"] abfragen.
With the first link the chain is forged. The first speech censored, the first thought forbidden, the first freedom denied, chains us all irrevocably.
Aaron Satie
Legends... are the spice of the universe, Mr. Data, because they have a way of sometimes coming true.
Captain Jean-Luc Picard, Stardate ~41294.5
Tutorials.de chattet. Hier gibts auch .net Support ^^
Klickt auf chattet und nutzt den Webchat, oder verbindet euch zu irc.tutorials.de - Channel #Tutorials.de
(moo)blog furred.net // SiteInfo für WP7 // Pastebin für WP7 // BlogEngine.net Extensions
-
Hi,
wunderbar, vielen Dank. Das werde ich gleich mal ausprobieren.
Viele Grüße und vielen Dank
Fridulin
--- Edit ---
Das hat wunderbar geklappt. Vielen Dank noch einmal
GrüßeGeändert von Fridulin (06.11.05 um 22:31 Uhr)
Ähnliche Themen
-
[C#] Dateidownload ab einer bestimmten Position der Datei beginnen
Von Fabsch im Forum .NET Web und KommunikationAntworten: 0Letzter Beitrag: 09.01.08, 16:15 -
Datei Umbenennen (Dateidownload)
Von MadCrusher im Forum PHPAntworten: 5Letzter Beitrag: 04.10.07, 15:55 -
Größe von ContextMenu ermitteln
Von schlechte_laune_bär im Forum .NET ArchivAntworten: 1Letzter Beitrag: 16.08.04, 13:31 -
Dateidownload -> Datei im Cache
Von jayjay im Forum Visual Basic 6.0Antworten: 1Letzter Beitrag: 07.09.03, 20:04 -
HTTP Header Parsen um Error Code zu ermitteln
Von finsh im Forum PHPAntworten: 0Letzter Beitrag: 10.04.03, 14:26





Zitieren

Login





