如题: 比如D:\123\  这个文件夹下面有文件: A.doc , B.doc  , C.doc
比如用户在一个文本框中输入 b.doc 然后搜索  能在页面中显示 b.doc
请大家给我一点思路?

解决方案 »

  1.   


    string path =@"D:\123\"+TextBox.Text;
    FileInfo file = new FileInfo(path);
    if(file.Exists)
      Label1.Text = path;
      

  2.   

    能不能实现模块搜索呀。比如文件名是  abcd.doc  我们直搜索 b然后它也能显示出来?
      

  3.   

    1. 你得有权限访问 目标目录2. 模糊查询string[] filePathArray  = System.IO.Directory.GetFiles(directoryPath, "*b*.doc");
      

  4.   

        protected void DownloadDir(string filename)//filename 为文件夹名称
        {
            string path = Server.MapPath(filename);
            DirectoryInfo di = new DirectoryInfo(path);
            FileInfo[] fs = di.GetFiles();
            string webRoot = Server.MapPath("");
            string filepath = "";        for (int i = 0; i < fs.Length; i++)
            {
                    if (i == fs.Length - 1)
                    {
                        filepath += ("" + fs[i].FullName.Replace(webRoot, "").Replace("\\", "/").TrimStart('/') + "");
                    }
                    else
                    {
                        filepath += ("" + fs[i].FullName.Replace(webRoot, "").Replace("\\", "/").TrimStart('/') + ",");
                    }
        }filepath内存储的就是文件夹filename下的所有文件,你可适当改变程序,实现你要的效果