我試圖找出以下問題,但我無法做到這一點,因爲我剛剛開始編程一個月前。從列表框中的項目下載多個文件
我有20個項目列表框:
private void loadDownloadXMLListBox()
{
var items = new[] { "BARC", "DEV", "DOM", "EZJ", "GFS",
"IHG", "JD.", "LAD", "LLOY", "MRW",
"NXT", "OCDO", "RBS", "SMWH", "SPD",
"STAN", "SYR", "TALK", "TSCO", "WMH" };
foreach (var item in items) listDownloadXML.Items.Add(item);
listDownloadXML.SelectedIndex = -1;
}
這是我從網站上下載一個選定的文件代碼:
private void btnDownloadXML_Click(object sender, EventArgs e)
{
using (WebClient client = new WebClient())
{
client.DownloadFile("http://www.lse.co.uk/chat/" + listDownloadXML.SelectedItem,
@"..\..\sharePriceXML\" +
listDownloadXML.SelectedItem + ".xml");
}
MessageBox.Show("Download Completed! File has been placed in the folder sharePriceXML!");
}
我想點擊一個按鈕「下載所有「那麼,網站上的所有20個項目都將被下載。我是否可以知道如何循環訪問列表框中的20個項目並將它們全部下載到文件夾中而不選擇項目?謝謝。
謝謝你的幫助。 :) – Shyuan 2012-08-19 15:38:21