如何使用WebClient的下载将文件下载到特定位置

时间:2019-11-25 22:08:36

标签: c# winforms

loop LDA current
     OUT
     ADD one
     STA current
     SUB until
     BRZ exit
     BRA loop
exit LDA until
     OUT
     HLT

current DAT 0
until   DAT 10
one     DAT 1

<script src="https://cdn.jsdelivr.net/gh/trincot/lmc@v0.6/lmc.js"></script>

使用上面的代码,我在线下载了图像,现在如何将文件的位置设置为其他位置,而不是将其放置在using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Net; namespace Garfield { public partial class Form1 : Form { public Form1() { InitializeComponent(); download("https://d1ejxu6vysztl5.cloudfront.net/comics/garfield/2019/2019-11-25.gif?v=1.1", "e.gif"); } public void download(string link, string name) { using (WebClient Client = new WebClient()) { Client.DownloadFile(link, name); } } private void Form1_Load(object sender, EventArgs e) { } } 文件夹中?

2 个答案:

答案 0 :(得分:0)

您可以将整个路径传递给def myfunc(s1, s2): nums = [int(i) for i in s1.split(", ")] squares = {int(i) for i in s2.split(", ")} return ", ".join([str(num) for num in nums if num * num in squares]) string1 = "2, 5, 3, 11" string2 = "19, 25, 4, 181" string3 = myfunc(string1, string2) print(string3) 方法:

2, 5

只需将download之前的所有内容替换为所需的路径即可。

在此处查看更多信息:https://docs.microsoft.com/en-us/dotnet/api/system.net.webclient.downloadfile?view=netframework-4.8

答案 1 :(得分:0)

这可以通过在下载时提及有效的所需位置和名称来完成。

Client.DownloadFile("https://d1ejxu6vysztl5.cloudfront.net/comics/garfield/2019/2019-11-25.gif?v=1.1",
    @"C:\yourfolder\yourfilename.png");
相关问题