2016-01-02 55 views
0

我想读取jpg文件的属性。 以下是我迄今为止所做的,但我无法获得图像中显示的属性“A”。我从下面得到的函数是带有ASCII &数值的字符串列表。从jpg文件中读取扩展图像属性

static void ReadProperties(Image imgImage) 
    { 
     var listImageProperties =new List<string>(); 
     try 
     { 
      PropertyItem[] propItems = imgImage.PropertyItems; 

      foreach (PropertyItem propItem in propItems) 
      { 
       listImageProperties.Add("0x" + propItem.Id.ToString("x")); 
       listImageProperties.Add(propItem.Type.ToString()); 
       listImageProperties.Add(propItem.Len.ToString()); 
      } 
     } 
     catch (Exception ex) 
     { 

     } 
    } 

enter image description here

+0

请注意,'属性'是文件系统的概念,与Exif无关。如果您还想从图像中读取Exif信息,请查看我的[metadata-extractor](https://github.com/drewnoakes/metadata-extractor-dotnet)库,它将读取您的各种元数据图像和视频文件。 –

回答

1

我有点调试后的答案。 以下代码读取文件属性。

var info = new FileInfo(path); 
var att= info.Attributes;//Attributes are enum for ReadOnly, Archive... & so on.