title: C# IOException Cannot locate resource
body: <p>I have a C# project where I have some PNG files in a <em>Images</em> directory.</p>
  <p>The structure of the project can be simplified to:</p>
  <pre><code>|
  ViewModel.cs
  View.xaml
  |
  [Images]
      \
      MapImageLayer16.png
  </code></pre>
  <p>In my view I bind to an object containing a string property <em>ImagePath</em>, pointing to <code>../Images/MapImageLayer16.png</code>, and another string property <em>Name</em>:</p>
  <pre><code>&lt;ListBox x:Name=&quot;DataLayerList&quot; ItemsSource=&quot;{Binding LayersFiltered, Mode=OneWay}&quot;&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;StackPanel Orientation=&quot;Horizontal&quot;&gt;
                  &lt;Image Source=&quot;{Binding Path=ImagePath}&quot; Height=&quot;16&quot;/&gt;
                  &lt;TextBlock Text=&quot;{Binding Path=Name}&quot;/&gt;
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  <p>Now, the name comes trough fine. However, the image fails with the following description:</p>
  <p><em>Failed to convert value '/Images/MapImageLayer16.png' (type 'String') to the target type using converter 'TargetDefaultValueConverter'. The fallback value will be used if it's available. IOException:'System.IO.IOException: Cannot locate resource 'images/mapimagelayer16.png'.</em></p>
  <p>I tried all sorts of things by now:</p>
  <ul>
  <li>changed the string value to ../Images/MapImageLayer16.png</li>
  <li>changed the string value to pack://application:,,,/Images/MapImageLayer16.png</li>
  <li>switched from string to Uri</li>
  </ul>
  <p>Nothing works! How can I get the PNGs to show?</p>