Show files from 2 different folders in a single Gridview

后端 未结 3 558
滥情空心
滥情空心 2021-01-26 08:08

Is it possible to show files from 2 different folders (c:\\test1 and c:\\test2) in the same gridview?

I work in VB.net (VS 2010)

Thanks!

3条回答
  •  故里飘歌
    2021-01-26 08:58

    Yes. Get list of all the files using Directory.GetFiles() into a single IEnumerable and bind it to a GridView.

    This is how you'll do it in c#.

                List allFiles = new List();
                allFiles.AddRange(Directory.GetFiles(@"C:\test1\*"));
                allFiles.AddRange(Directory.GetFiles(@"C:\test2\*"));
    
                yourGV.DataSource = allFiles;
                yourGV.DataBind();
    

提交回复
热议问题