简体   繁体   English

我想使用c#从HTTPS链接的文件夹中下载名称以特定字符串开头的文件

[英]I wanted to download files whose name start with a particular string from a folder in an HTTPS link using c#

I wanted to download files whose name start with a particular string from a folder in an HTTPS link using c# , for this example my file start with test but i dont know the XXXX characters 我想使用c#HTTPS链接的文件夹中下载名称以特定字符串开头的文件,在本示例中,我的文件以test开头,但是我不知道XXXX字符

WebClient webClient = new WebClient();
webClient.Credentials = new NetworkCredential("login", "pass");
webClient.DownloadFile("https://domain.com/testXXXX.zip", "d://file.zip");

i have already tested the code with a file whose name i already know and it worked perfectly 我已经用一个我已经知道其名称的文件测试了该代码,并且运行良好

Any help please ? 有什么帮助吗?

please use this to get all file that meet ur crateria and then apend the to ur url 请使用此文件获取符合ur crateria的所有文件,然后将其附加到ur url

var fileEntries = Directory.GetFiles("").Where(x=>x.StartsWith("test"));
           foreach (var fi in fileEntries )
            {
                WebClient client = newWebClient();
                client .Credentials = new NetworkCredential("login", "pass");
                yourUrl=  yourUrl +fileName
                client.DownloadFileAsync(yourUrl, destinationhere);
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM