【发布时间】:2013-12-13 12:56:04
【问题描述】:
我想制作控制台 c# 程序以从 web 下载和执行 program.exe 文件。 所以当我运行这个程序时出现“Webexception unhandle”错误。任何人都可以帮助我。谢谢
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Diagnostics;
using System.IO;
namespace Downloader{
class Program
{
static void Main(string[] args)
{
Uri uri = new Uri("http://www.pendrivelinux.com/downloads/Universal-USB-Installer/Universal-USB-Installer-1.9.5.1.exe");
string filename = @"C:\bootable.exe";
using (var wc = new WebClient())
{
wc.Credentials = CredentialCache.DefaultCredentials;
wc.Headers.Add(HttpRequestHeader.UserAgent, "anything");
wc.DownloadFile(uri, filename);
}
}
}
}
谁能帮帮我。
【问题讨论】:
-
显示你得到的错误。它可能包含很多关于为什么您的下载不起作用的提示。
标签: c# exception-handling