且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

下载保存并运行

更新时间:2023-12-05 16:36:28

尝试一下(如果通过运行它您的意思是使用默认应用程序将其打开):

Try this maybe (if by run it you meant open it with default application):

using (WebClient Client = new WebClient())
{
    FileInfo file = new FileInfo("filename.jpeg");
    Client.DownloadFile("http://vx.zapto.org/newscript/enone.jpg", file.FullName);
    MessageBox.Show("Downloaded!");

    Process.Start(file.FullName);
}

请注意,第二个参数 WebClient.DownloadFile(..) 是文件名,而不是扩展名。

Note that the second parameter to WebClient.DownloadFile(..) is a filename, not an extension.