Error Handling while downloading from FTP site

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjuk
    New Member
    • Nov 2008
    • 2

    Error Handling while downloading from FTP site

    Hello

    Problem: I need to download files from an FTP site while moving very fast.
    I expect connection problems during downloads. If a file is half downloaded and there is a connection glitch, then the file needs to be downloaded fully once again. Likewise, different actions have to be taken based on the error.

    How to handle error cases using WebClient.Downl oadFile? Or are there any other better APIs?

    --- sample code ---
    WebClient fileGetter = new WebClient();
    fileGetter.Cred entials = new NetworkCredenti al(userName, passWord);

    //download files
    fileGetter.Down loadFile(source , destPath);
    ----
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Use try/catch blocks

    Comment

    Working...