有datagridview控件,绑定了多个数组中的部分数据。
this.m_file = new string[]
{
"2002\\01\\0001.pdf",
"2002\\01\\0002.pdf",
"2002\\01\\0003.pdf",
"2002\\01\\0004.pdf",
                                                . 
                                                .
                                                .
                                        "2002\\05\\0008.pdf"  };
   2002文件件里有(01、02、03、04......12)个子文件夹,01中有(0001.pdf、002.pdf.......)
 this.webBrowser1.Url = new Uri("E:\\2002\\01\\0001.pdf");这个能显示指定的pdf

现在我点击其中的一行(假如这一行在数组中的索引是i),那么,如何根据i把文件夹里的对应的pdf文件显示在webBrowser

解决方案 »

  1.   

    geyunfei_hit :
                   你好,请问如何遍历2002文件夹下的12个子文件夹并找到对应的那个pdf呢?我是以索引变量 i 为条件的 .
      

  2.   

    System.IO;命名空间下的 目录 文件操作类(FileInfo File Directory)
      

  3.   

    代码如下:
    string[] strPath = Directory.GetDirectories("E:\\2002");
                    for(int i=0;i<strPath.Length; i++)
                    {
                        DirectoryInfo di = new DirectoryInfo(strPath[i]);
                        FileInfo[] fi = di.GetFiles("*.pdf");
                        foreach (FileInfo f in fi)
                        {
                         MessageBox.Show(f.FullName);
                                            
                        }
                    }
      

  4.   

    this.webBrowser1.Url = new Uri("E:\\" + m_file[i]);搞定