下载保存并运行 [英] Download Save And Run

查看:70
本文介绍了下载保存并运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试下载文件并比C#运行该文件,但效果有限。这是我的脚本:

I have been trying to download a file and run it than C#, with limited success. Here's my script:

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

有人可以帮助吗?

推荐答案

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

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.

这篇关于下载保存并运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆