DirectoryInfo sddirinfo = new DirectoryInfo("c:\\");
FileInfo [] sdsysinfo = sddirinfo.GetFiles();
FileInfo sdfi;DirectoryInfo sddi;
DirectoryInfo sddirinfo = new DirectoryInfo(sddir);
foreach(FileSystemInfo sdsysinfo in sddirinfo.GetFileSystemInfos())
{sdfilename = "";sdfileext = "";sdfilesize = 0;
if(sdsysinfo is FileInfo)
{sdfi = (FileInfo)sdsysinfo;
sdfilename = sdfi.Name;
sdfileext = sdfi.Extension;
sdfilesize = sdfi.Length;
sdfiletime = sdfi.CreationTime;
每句什么意思?
DirectoryInfo sddirinfo = new DirectoryInfo("c:\\");//定义DirectoryInfo变量,并指向C:\
FileInfo [] sdsysinfo = sddirinfo.GetFiles();//获得C:\下的文件,并存入FileInfo类型数组
FileInfo sdfi;DirectoryInfo sddi;
DirectoryInfo sddirinfo = new DirectoryInfo(sddir);
foreach(FileSystemInfo sdsysinfo in sddirinfo.GetFileSystemInfos())
{sdfilename = "";sdfileext = "";sdfilesize = 0;
if(sdsysinfo is FileInfo)
{sdfi = (FileInfo)sdsysinfo;
sdfilename = sdfi.Name;//获得文件名称
sdfileext = sdfi.Extension;//获得文件扩展名
sdfilesize = sdfi.Length;//获得文件大小
sdfiletime = sdfi.CreationTime;//获得文件创建日期