Click here to Skip to main content
15,915,094 members
Home / Discussions / C#
   

C#

 
AnswerRe: Help with excel and hyperlinks - ANWSER HERE Pin
turbosupramk310-Feb-11 10:35
turbosupramk310-Feb-11 10:35 
QuestionDesktop application and DB on web server Pin
AlexB479-Feb-11 5:36
AlexB479-Feb-11 5:36 
AnswerRe: Desktop application and DB on web server Pin
#realJSOP9-Feb-11 5:40
professional#realJSOP9-Feb-11 5:40 
GeneralRe: Desktop application and DB on web server Pin
Manfred Rudolf Bihy9-Feb-11 7:53
professionalManfred Rudolf Bihy9-Feb-11 7:53 
AnswerRe: Desktop application and DB on web server Pin
Eddy Vluggen9-Feb-11 6:33
professionalEddy Vluggen9-Feb-11 6:33 
AnswerRe: Desktop application and DB on web server Pin
PIEBALDconsult9-Feb-11 15:09
mvePIEBALDconsult9-Feb-11 15:09 
Questionsome or all identity references could not be translated Pin
Enobong Adahada9-Feb-11 1:12
Enobong Adahada9-Feb-11 1:12 
QuestionIt doesnt download every file Pin
Member 21681038-Feb-11 23:58
Member 21681038-Feb-11 23:58 
Why doesnt it download every files in this code?
All files that have been downloaded is shown in the listview, but when i open the folder where the files are, then some of files has not been downloaded.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnDownload_Click(object sender, EventArgs e)
        {

            string p1 = @"\";
            string p2 = TBSaveTo.Text;
            string p3 = TBSaveAs.Text;
            

            listView1.Items.Clear();
            label1.Visible = false;

            HttpWebRequest request = null;
            HttpWebResponse response = null;
            WebClient wc = new WebClient();

            string ret = "";

            for (int i = 2000; i < 2312; i++)
            {
                string sFiles = string.Format("http://www.svenskaspel.se/includes/xmlelements/XMLresultat.asp?produktid=30&omgang={0}", +i);

                listView1.Items.Add(new ListViewItem(p2 + p1 + "omgang=" + i + p3));


                {

                    try
                    {
                        // Create a request to the files we are downloading
                        request = (HttpWebRequest)WebRequest.Create(sFiles.Trim());
                        request.Method = "GET";
                        request.ContentType = "application/x-www-form-urlencoded";
                        request.Timeout = 15000;
                        // Retrieve the response from the server
                        response = (HttpWebResponse)request.GetResponse();
                        ret = new StreamReader(response.GetResponseStream(),
                                                      Encoding.Default).ReadToEnd();



                        wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
                        //Save Files To Folder
                        wc.DownloadFileAsync(new Uri(sFiles.Trim()), String.Format(p2 + p1 + "omgang=" + i + p3, Path.GetExtension(sFiles)));
                        wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted);
                        response.Close();

                    }
                    catch { }

                    finally
                    {
                        if (response != null)
                        {
                            response.Close();


                        }

                    }

                }
            }
        }




        private void wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {


            this.label1.Visible = false;
        }

        private void wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            this.label1.Visible = true;
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                TBSaveTo.Text = folderBrowserDialog1.SelectedPath;
            }
        }
    }
}


/Kenneth
AnswerRe: It doesnt download every file Pin
Luc Pattyn9-Feb-11 0:26
sitebuilderLuc Pattyn9-Feb-11 0:26 
GeneralRe: It doesnt download every file Pin
DaveyM699-Feb-11 0:37
professionalDaveyM699-Feb-11 0:37 
AnswerRe: It doesnt download every file Pin
Member 21681039-Feb-11 0:56
Member 21681039-Feb-11 0:56 
GeneralRe: It doesnt download every file Pin
#realJSOP9-Feb-11 5:41
professional#realJSOP9-Feb-11 5:41 
QuestionRe: It doesnt download every file Pin
Member 216810325-Feb-11 3:35
Member 216810325-Feb-11 3:35 
AnswerRe: It doesnt download every file Pin
Pete O'Hanlon9-Feb-11 1:01
mvePete O'Hanlon9-Feb-11 1:01 
GeneralRe: It doesnt download every file Pin
Luc Pattyn9-Feb-11 1:32
sitebuilderLuc Pattyn9-Feb-11 1:32 
GeneralRe: It doesnt download every file Pin
Pete O'Hanlon9-Feb-11 2:17
mvePete O'Hanlon9-Feb-11 2:17 
GeneralRe: It doesnt download every file Pin
#realJSOP9-Feb-11 5:42
professional#realJSOP9-Feb-11 5:42 
QuestionCopy TreeViewItem WPF .NET 4.0 Pin
Mc_Topaz8-Feb-11 23:02
Mc_Topaz8-Feb-11 23:02 
AnswerRe: Copy TreeViewItem WPF .NET 4.0 Pin
Pete O'Hanlon9-Feb-11 1:11
mvePete O'Hanlon9-Feb-11 1:11 
GeneralRe: Copy TreeViewItem WPF .NET 4.0 Pin
Mc_Topaz9-Feb-11 1:38
Mc_Topaz9-Feb-11 1:38 
GeneralRe: Copy TreeViewItem WPF .NET 4.0 Pin
Pete O'Hanlon9-Feb-11 2:11
mvePete O'Hanlon9-Feb-11 2:11 
QuestionVideo Streaming Pin
Rei ho8-Feb-11 18:27
Rei ho8-Feb-11 18:27 
AnswerRe: Video Streaming Pin
Abhinav S8-Feb-11 18:51
Abhinav S8-Feb-11 18:51 
GeneralRe: Video Streaming Pin
Rei ho8-Feb-11 19:35
Rei ho8-Feb-11 19:35 
QuestionHow to send files with http protocol between 2 pc or many Pin
omercansasal8-Feb-11 3:52
omercansasal8-Feb-11 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.