Thread: Freezing When Download

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    16

    Freezing When Download

    Hi,

    I made a program and when i'm downloading the file, the program freeze, what do i have to do?

    I'm newbie!


    PHP Code:
    string url "http://mysite.com.br/test.mst";
                
    string destino "C:\\Programas\\teste.mst";
                
    System.Net.WebClient Client = new System.Net.WebClient();
                
    Client.DownloadFile(urldestino); 

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    How big is the file?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1 - This is the C forum. Perhaps a mod will move your post.
    2 - Don't spam the board with posts on the same topic. We'll assume you hit the button twice on accident.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    1 - That looks like C#. Moved.
    2 - The boards been slow, so that's probably the case.

    Your post count is zero, despite the fact that you have one post in this thread. I screwed something up while deleting the duplicate thread which caused your post count to be decremented twice.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    16
    1 - That looks like C#. Moved.
    2 - The boards been slow, so that's probably the case.
    You are right in bouth

    But continuing.. How can helps me?

    And the file is to small (20kb)

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Well, I don't know anything about C#, but maybe google can help you: http://www.google.com/search?hl=en&q=download+file+c%23
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User
    Join Date
    Dec 2005
    Posts
    16
    i have search all google already but didn't found anything that may fix that problem.

  8. #8
    Registered User
    Join Date
    Dec 2005
    Posts
    16
    Anybody know what could be freezing the program when it's downloading the file?

  9. #9
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    I have tried recreating your "freezing" problem using the DownloadFile method. I did not have any success recreating the problem. The method was tested with several source sites and file sizes ranging from 18K to 14meg.

    IMHO, it may be that your source site is extremely slow or it has some other downloading issues. Or you possibly have coding issues. I can only assume that you have properly used a separate thread for the downloading process in a GUI app.

    Bottomline, DownloadFile works flawlessly for me.

  10. #10
    Registered User
    Join Date
    Dec 2005
    Posts
    16
    the file i'm trying to download has 1.7mb!
    I tried downloading another file from another site and it freezes again.

    Please, can u post your 'creation'?

  11. #11
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    My "creation" works like a charm... It may be possible your GUI code has threading issues. Thus, causing the "freeze" problem.

    Code:
    using System;
    using System.Web;
    using System.IO;
    using System.Net;
    using System.Collections;
    
    class Class1
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
            static void Main(string[] args)
            {
            string url =   "http://mysite.com/haha.mst"; 
            string destino = "C:\\temp\\test.mst"; 
            try
            {
                WebClient client = new WebClient ();
                client.DownloadFile(url, destino); 
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Download large files with dial-up...
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 10-18-2007, 08:02 PM
  2. Replies: 4
    Last Post: 09-30-2005, 02:51 AM
  3. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM