XmlDocument doc = new XmlDocument();
doc.Load(@"D:\Project\C#Test\WindowsApplication1\WindowsApplication1\XMLFile1.xml"); XmlNodeList nodeList = doc.SelectNodes("//LocalFileList//FileName");
List <string> values = new List <string>();
foreach (XmlElement element in nodeList)
{ if (!values.Contains(element.InnerText))
{
Debug.WriteLine(string.Format("FileName:{0}", element.InnerText));
values.Add(element.InnerText);
}
}显示过后,如何下载那些文件喃?现在路径保存在一个变量里。
比如:a
该如何写喃?
谢谢啊
doc.Load(@"D:\Project\C#Test\WindowsApplication1\WindowsApplication1\XMLFile1.xml"); XmlNodeList nodeList = doc.SelectNodes("//LocalFileList//FileName");
List <string> values = new List <string>();
foreach (XmlElement element in nodeList)
{ if (!values.Contains(element.InnerText))
{
Debug.WriteLine(string.Format("FileName:{0}", element.InnerText));
values.Add(element.InnerText);
}
}显示过后,如何下载那些文件喃?现在路径保存在一个变量里。
比如:a
该如何写喃?
谢谢啊
把文件名(带路径)和你下载显示的文件标题作为参数传入就行 private void DownLoad(string filepath, string filetitle)
{
System.IO.FileInfo fi=new System.IO.FileInfo(filepath);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.Buffer = false;
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filetitle, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", fi.Length.ToString());
System.Web.HttpContext.Current.Response.WriteFile(fi.FullName);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}
mydoc.Load("AutoUpdater.xml");
string a = mydoc.GetElementsByTagName("URLAddres")[0].InnerText; int b = chFileName.ListView.Items.Count;
while (b > 0)
{
b = b-1;
string DFILE = chFileName.ListView.Items[b].Text;
string filePath = a + DFILE;
WebClient Client = new WebClient();
Client.DownloadFile(filePath, @"C:\TEMP\downfile\" + DFILE);
}