日期:2014-05-18  浏览次数:20449 次

如何读取指定文件夹里的文件
现存放于固定 “E:/大纲/ ” 路径下有多个文档 1.doc ,2.doc ,.... 等。请问如何读取此路径下的所有文件。另物理路径“E:/大纲/ ”能否写在Web.Config 中,这样方便以后如果路径改变只需改配置文件。请问如何实现?

------解决方案--------------------
System.IO.DirectoryInfo d = new System.IO.DirectoryInfo("E:\\大纲\\");
System.IO.FileInfo[] fs = d.GetFiles("*.doc");
foreach (System.IO.FileInfo f in fs)
{
Response.Write("<li>" + f.FullName);
}
可以配置到config里面

读取方法
System.Configuration.ConfigurationManager.AppSettings["path"].ToString()