Search code examples
c#wpfimageembed

C# Wpf embed images at runtime


In my C# WPF application the user have the possibility to import pictures. Currently the source of the image is referenced to the picture path.

When the picture will be deleted or moved, then my reference is not valid anymore. How is it managed in applications like Word or Photoshop? Is it possible to embed the picture at runtime in my custom file? Or should these files copied to a "image database"?


Solution

  • In Microsoft Word (docx) format. When you paste images in the document, it saves them as file(s). Try this:

    1. Rename the .docx to .zip extension
    2. Extract the zip archive

    Now, navigate to the following and you can see all the embeded images here: enter image description here

    You can do something similar for your app. Without knowing the full context and design details its difficult to answer where should the images go. Generally speaking, images should/could be co-located with the rest of the data that image compliments.