string folder = context.Server.MapPath("/Excel"); //获取文件夹URL
List<string> list = new List<string>();
//有子目录的情况
string[] dires = Directory.GetDirectories(folder);
foreach (string dire in dires)
{
string[] filepart = dire.Split('\');
string filename = filepart[filepart.Length - 1].ToString();//析取文件名
GetExcelName(context);
list.Add(filename);
}
//排除子目录,直接获取名称
string[] files = Directory.GetFiles(folder);
foreach (string file in files)
{
string[] filepart = file.Split('\');
string filename = filepart[filepart.Length - 1].ToString();
list.Add(filename);
}
return list;