我正在使用SHGetFileInfo将项目(文件)添加到带有图标和文件类型的Listview。我想添加文件创建时间&同样功能的文件大小。根据MSDN,我可以从SHGFI_ATTR_SPECIFIED标志中提取这些,但到目前为止我还没有做过这样的事情,所以我有点迷失......这是我到目前为止所做的:
foreach (FileInfo file in dir.EnumerateFiles())
{
IntPtr file_properties = SHGetFileInfo(file.FullName, 0,
ref shfi, (uint)Marshal.SizeOf(shfi),
SHGFI_ATTR_SPECIFIED | SHGFI_TYPENAME | SHGFI_DISPLAYNAME |
SHGFI_SYSICONINDEX
| SHGFI_SMALLICON |SHGFI_USEFILEATTRIBUTES);
lvi = new ListViewItem();
lvi.Tag = file.FullName;
lvi.Text = shfi.szDisplayName;
lvi.SubItems.Add(file.LastWriteTime.ToShortDateString() //I would like to add these with SHGetFileInfo if possible
+ " " + file.LastWriteTime.ToShortTimeString());
lvi.SubItems.Add(shfi.szTypeName);
lvi.SubItems.Add(shfi.dwAttributes.ToString()); //this returns 0
lvi.ImageIndex = shfi.iIcon;
Listivew1.Items.Add(lvi);
}