直接使用C#遍历指定文件夹中的所有文件就可以实现;
参考如下:
DirectoryInfo TheFolder=new DirectoryInfo(folderFullName);
//遍历文件夹
foreach(DirectoryInfo NextFolder in TheFolder.GetDirectories())
this.listBox1.Items.Add(NextFolder.Name);
//遍历文件
foreach(FileInfo NextFile in TheFolder.GetFiles())
this.listBox2.Items.Add(NextFile.Name);
foreach (string file in files)
Response.Write(Path.GetFileName(file));
DirectoryInfo dicInfo = new DirectoryInfo(detailDrawingDirector);
List
if (dicInfo.Exists) {
FileInfo[] infos = dicInfo.GetFiles();
foreach (FileInfo info in infos) {
Response.Write(info.Name);
}
用substring处理一下file。
.......
file.Substring(file.LastIndexOf("\\")+1,file.Length()-1);
Response.Write(file);
///
/// 查找指定文件夹下的文件 只支持第一级的文件
///
///
///
public ListGetFiles(string folderFullName)
{
var list = new List();
DirectoryInfo folder = new DirectoryInfo(folderFullName);
if (folder!=null && folder.GetFiles().Length>0)
{
//遍历文件
foreach (FileInfo nextFile in folder.GetFiles())
{
list.Add(nextFile);
}
}
return list;
}