C# MetadataExtractor无法在控制台外打印信息的原因

C# MetadataExtractor无法在控制台外打印信息的原因,c#,.net,winforms,C#,.net,Winforms,伙计们,我有个问题,也许有人知道答案。我今天使用MetadataExtractor,一切都很好,但有一件事。所有的信息都进入了数据库 我不能把他们从那里弄出来。。。 有人知道如何将信息添加到标签中吗?我甚至不能获得这些信息 var directories = ImageMetadataReader.ReadMetadata(filename); // print out all metadata foreach (var directory in direct

伙计们,我有个问题,也许有人知道答案。我今天使用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);
var directories=ImageMetadataReader.ReadMetadata(文件名);
//打印出所有元数据
foreach(目录中的var目录)
foreach(directory.Tags中的var标记)
Console.WriteLine($“{directory.Name}-{tag.Name}={tag.Description}”);
//访问日期和时间
var subIfdDirectory=目录.OfType().FirstOrDefault();
var dateTime=subIfdDirectory?.GetDateTime(ExifDirectoryBase.TagDateTime);
我这样解决了它(您需要MetadataExtractor包


因为这对我来说太难了,所以要在不同的标签中获取所有信息我只使用了一个标签,每次只添加文本。

您希望控制台.WriteLine的输出到哪里?您也可以轻松地获取正在构造的字符串,然后用它做其他事情。@RetiredInja字符串应该放在不同的标签中。我现在想了一种方法,字符串可以放在列表框中,但我只需要信息,但他也给了我一个描述……控制台没有标签,您可能正在寻找不同的应用程序类型,如winforms或wpf。事实上,这个问题令人困惑。定义您认为控制台是什么,明确说明您是什么技术和应用程序类型using@MichaelRandall哦,对不起。。我正在使用WinForms。那么它是如何在控制台中结束的,在WinForms中获得一个控制台需要很多工作,您是否正在描述IDE输出窗口?
// 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();
        }

    }