webclient异常已被调用目标抛出

时间:2013-03-09 06:15:53

标签: c# wpf

我想使用webclient的DownloadFile函数,但是我使用断点来查看哪个行有错误。它只是在DownloadFile时捕获阻塞。

            try
            {
                string myStringWebSource = this.curFtpIp + FtpCuPath + "/" + FtpdfName + "/" + this.lbl.Text;

                WebClient client = new WebClient();
                client.Credentials = new NetworkCredential(this.FtpUserID, this.FtpPassword);
                client.DownloadFile(myStringWebSource, SaveFile);
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }
            finally { }

1 个答案:

答案 0 :(得分:1)

我已经解决了我自己的问题。我发现我设置了错误的第二个参数。我只使用“SaveFile”这是保存路径,但它应该是一个文件名。所以,我刚刚修改了SaveFile,它可以工作。

WebClient.DownloadFile MSDN