예제 #1
0
        /* Methode für den Schalter zum synchronen Download */
        private void syncDownloadAsFile_Click(object sender, System.EventArgs e)
        {
            FileStream fs = null;

            try
            {
                // FileStream für die Datei erzeugen
                fs = new FileStream(this.destFileNameTextBox.Text,
                                    FileMode.Create, FileAccess.Write);

                // Datei herunterladen
                WebDownload webDownload = new WebDownload();
                webDownload.DownloadSync(this.urlTextBox.Text, fs, 1024,
                                         new WebDownload.DownloadProgress(this.DownloadProgressHandler), null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                // FileStream schließen
                try { fs.Close(); }
                catch {}
            }
        }