I am trying to read the metadata from a .tif file using the Metadata Extractor dll and I keep getting a FileIsNotFoundException. It works fine when I try the same code using a .jpeg file.
FileStream OriginalFile = new FileStream(FullPath, FileMode.Open, FileAccess.Read, FileShare.Read);
IEnumerable<MetadataExtractor.Directory> directories = ImageMetadataReader.ReadMetadata(OriginalFile);
foreach (var directory in directories)
foreach (var tag in directory.Tags)
Console.WriteLine($"{directory.Name} - {tag.Name} = {tag.Description}");
Edit : I re-installed the package and now have the XmpCore.dll inside the packages folder of my project but I still see the same exception as before. Works fine for .jpeg and .psd files.
FileNotFoundException means that your FullPath doesn't contain a file that's actually on disk.
Try adding:
Console.WriteLine(FullPath);
Console.WriteLine(File.Exists(FullPath));
Also double check between .tif and .tiff.
EDIT Your screenshot shows the missing file is XmpCore.dll
. When you added the NuGet reference to MetadataExtractor
, you should also have picked up XmpCore
.
Here's an example of packages.config
:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MetadataExtractor" version="1.5.3" targetFramework="net45" />
<package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
<package id="XmpCore" version="1.2.2" targetFramework="net45" />
</packages>
Ensure you also have the relevant project references.
After building a new .NET 4.5 console project with the above packages.config
, the bin/Debug
folder looked like this:
And the contents of the packages
folder:
我通过将解决方案资源管理器中“引用”下的XmpCore的“复制本地”属性更改为True来解决了该异常。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.