如何在c#中创建一个系统来检查主机上list.txt中所需文件的列表,并将每个文件分别添加到代码中?
If (! File.Exists ("each file in the list"))
{
WebClient client = new WebClient ();
Client.DownloadFileAsync (new Uri (site + "missing file"), dir + "name of downloaded file");
}
答案 0 :(得分:0)
试试这段代码:
var files = File.ReadAllLines("list.txt");
foreach (var filename in files)
{
if (!File.Exists(filename))
{
WebClient client = new WebClient();
client.DownloadFileAsync(new Uri(site + filename), dir + filename);
}
}