菜鸟问题(asp.net2.0)按文件名查找文件 急!!!!
各位大虾,现小弟有一页面,输入字符串,按“查询”按钮,到指定目录下(许多文件),按照输入字符串和文件名匹配进行查找。如找到则在查询页面显示文件路径,并提供下载。怎么实现??谢谢
------解决方案--------------------DirectoryInfo directInfo = new DirectoryInfo(dri) 
             if (directInfo.Exists) 
             { 
                 FileSystemInfo[] path = directInfo.GetFileSystemInfos() 
                 if (path.Length != 0) 
                 { 
                     foreach (FileSystemInfo file in path) 
                     { 
                         Response.Write(file.Name); //显示文件或路径名 
                         Response.Write(file.FullName);//显示文件或路径全名 
                         //然后在这里判断是否有该文件,有,则提取相对路径 
                     } 
                 } 
             }   
  注意:该路径必须具有相应权限,2000为ASPNE权限,2003为NETWORKSERVICE权限
------解决方案--------------------使用System.IO.Directory.GetFiles(string path,string searchPattern)这个方法,详细内容请看MSDN
------解决方案--------------------比如:查找当前目录下所有aspx文件
	System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(Server.MapPath( " "));
			System.IO.FileInfo[] fs = dir.GetFiles( "*.aspx ");
			foreach(System.IO.FileInfo f in fs)
			{
				Response.Write(f.Name + " <BR>  ");
			}