Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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!");
}

Can anyone help?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
146 views
Welcome To Ask or Share your Answers For Others

1 Answer

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);
}

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...