请问:多文件下载或者导出问题
服务器某文件夹里有 很多ascx文件
请问怎么实现让用户可以导出到自己的机器上 或者讲下载
string strPath = Server.MapPath( "..\\TemplateControl ");
DirectoryInfo di = new DirectoryInfo(strPath); ;
FileInfo[] fi = di.GetFiles();
foreach (FileInfo fiTemp in fi)
{
if (fiTemp.Extension == ".cs ")
{
ListItem li = new ListItem(fiTemp.Name.Split( '. ')[0].ToString(), fiTemp.Name.Split( '. ')[0].ToString());
DropDownList1.Items.Add(li);
}
}
------解决方案--------------------。。。
继续查
------解决方案--------------------和普通文件一样下载啊:
string name = Server.MapPath( "~/1.ascx ");
FileInfo aFile = new FileInfo(name);
Response.Clear();
Response.ClearHeaders();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream ";
Response.AppendHeader( "Content-disposition ", "attachment;filename=1.ascx ");
Response.AddHeader( "Content-Length ", aFile.Length.ToString());
Response.WriteFile(name);
Response.Flush();
Response.End();