string FilePic; //图像文件类型
long FileSize; //文件大小
DateTime FileModify; //最后更新时间
DirectoryInfo dir=new DirectoryInfo(strCurrentDir);
foreach(FileSystemInfo fsi in dir.GetFileSystemInfos())
{
FilePic="";
FileName="";
FileSize=0;
FileExt="";
if(fsi is FileInfo)
{
//表示当前fsi是文件
fi=(FileInfo)fsi;
FileName=fi.Name;
FileExt=fi.Extension;
FileSize=fi.Length;
FileModify=fi.LastWriteTime;
//通过扩展名来确定显示图片的类型
switch(FileExt)
{
case ".jpg":
FilePic="jpg图像";
break;
case ".gif":
FilePic="gif图像";
break;
case ".tiff":
FilePic="tiff图像";
break;
case ".bmp":
FilePic="bmp图像";
break;
default:
FilePic="文件";
break;
}
}
else
{
//当前为目录
di=(DirectoryInfo)fsi;
FileName=di.Name;
FileModify=di.LastWriteTime;
FilePic="目录";