DirectoryInfo info = new DrectoryInfo(configurationmanager.appsettings["Targetroot"].tostring ());
//FileInfo[] _files = info.GetFiles("You could set a search pattern");
//FileInfo[] _files = info.GetFiles("*.aspx");
FileInfo[] _files = info.GetFiles();
Gvfiles.datasource = _files;
Gvfiles.databind();
或者:
DirectoryInfo info = new DirectoryInfo(Server.MapPath("/"));
DirectoryInfo[] _info = info.GetDirectories();
for (int i = 0; i < _info.Length; i++)
{
FileInfo[] files = _info[i].GetFiles("search pattern");
Gvfiles.datasource = files;
Gvfiles.databind();
}