伙计们,我有一个问题,也许有人知道答案。我今天与MetadataExtractor一起工作,一切正常,但是有一件事。所有信息都进入了 控制台,我不能从那里拿出来... 有谁知道我如何将信息添加到标签?我什至无法访问信息...
var directories = ImageMetadataReader.ReadMetadata(filename);
// print out all metadata
foreach (var directory in directories)
foreach (var tag in directory.Tags)
Console.WriteLine($"{directory.Name} - {tag.Name} = {tag.Description}");
// access the date time
var subIfdDirectory = directories.OfType<ExifSubIfdDirectory>().FirstOrDefault();
var dateTime = subIfdDirectory?.GetDateTime(ExifDirectoryBase.TagDateTime);
答案 0 :(得分:0)
我这样解决了它(您需要MetadataExtractor软件包)
// access the date time
var subIfdDirectory = directories.OfType<ExifSubIfdDirectory>().FirstOrDefault();
var dateTime = subIfdDirectory?.GetDateTime(ExifDirectoryBase.TagDateTime);
//TEST
// print out all metadata
listBox2.Items.Clear();
foreach (var directory in directories)
{
foreach (var tag in directory.Tags)
listBox2.Items.Add($"{tag.Description}"); //Import just Information
}
然后我添加了一个计时器计时器,该计时器将从列表框中获取信息。计时器与进度栏一起使用,以获取信息。
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.Increment(1);
if(progressBar1.Value == 1)
{
listBox2.SelectedIndex = 20;
InfoLabel.Text += " Größe: " + listBox2.SelectedItem.ToString();
}
else if (progressBar1.Value == 2)
{
listBox2.SelectedIndex = 18;
InfoLabel.Text += " Format: " + listBox2.SelectedItem.ToString();
}
else if(progressBar1.Value == 3)
{
Bitmap img = new Bitmap(listBox1.SelectedItem.ToString());
var imageHeight = img.Height;
var imageWidth = img.Width;
listBox2.SelectedIndex = 3;
InfoLabel.Text += " Abmessung: " + img.Width + " x " + img.Height;
}
else if (progressBar1.Value == 4)
{
listBox2.SelectedIndex = 3;
InfoLabel.Text += " Breite: " + listBox2.SelectedItem.ToString();
}
else if(progressBar1.Value == 5)
{
listBox2.SelectedIndex = 2;
InfoLabel.Text += " Höhe: " + listBox2.SelectedItem.ToString();
}
else if(progressBar1.Value == 6)
{
listBox2.SelectedIndex = 19;
InfoLabel.Text += " Dateiname: " + listBox2.SelectedItem.ToString();
}
else
{
timer1.Stop();
}
}
因为对我来说太难了,所以将所有信息都放在不同的标签中,我只是使用了一个标签,每次都添加了文本。