我写的函数允许我获取任何文件的所有属性。
该功能甚至适用于文件夹。如何使用Windows API代码包获取根驱动器详细信息?
但我提到,如果没有“Windows API代码包”并使用“Shell32”,您可以提前获得大约308个任何文件的属性。
Shell32.Shell shell = new Shell32.Shell();
shell.NameSpace(@"C:\_test\clip.mp4").GetDetailsOf(null, i); // i = 0...320
但是,使用“Windows API代码包”的“DefaultPropertyCollection”集合中只有56个属性。
例如,此集合中没有“评级”属性。
后来我意识到,而不是“shellFile.Properties.DefaultPropertyCollection”我应该看看“shellFile.Properties.System”
private void GetFileDatails(string path)
{
var shellFile = ShellFile.FromParsingName(path);
textBox1.Text += shellFile.Properties.DefaultPropertyCollection.Count + "\r\n";
shellFile.Properties.DefaultPropertyCollection.ToList().ForEach(el => textBox1.Text += el.Description.CanonicalName + " - " + el.Description.DisplayName + " = " + el.ValueAsObject + "\r\n");
textBox1.Text += "\r\n" + shellFile.Properties.System.Rating;
}
赞成票这是真的!
但是如何使用这个“shellFile.Properties.System”获得所有其他200多个属性?
它甚至不收集!它不是IEnumerable!你不能使用foreach循环!
你应该总是键入
"shellFile.Properties.System.*" //you should type this line more then 100 times
反正我不能让根驱动器的详细信息也!
使用“Windows API代码包”或使用“Shell32” 我无法获得任何分区的“DriveFormat”! 请!告诉我如何获得“C Drive”细节?
如何获得任何驱动器“的DriveType”属性?无论是不是“固定”类型? – IremadzeArchil19910311
https://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx – Ben