I have a WPF Application project directory like this

Actually i have added a Folder named “Resources” inside Visual studio project and added some images into that.Physically the folder was created at above location.We can see that at above picture.Default properties of images inside “Resource”folder are given below
BuilAction:Resource
Copy output Directory:Do not Copy
I am reading an image called “form1.ico” file from this folder like this
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="MyApp.FrmMain"
Title="MyApp" Height="768" Width="1024" WindowStartupLocation="CenterScreen" x:Name="MainWindow" WindowStyle="None" Loaded="MainWindow_Loaded" ShowInTaskbar="False" ResizeMode="NoResize" WindowState="Maximized" mc:Ignorable="d" Icon="/MyApp;component/Resources/form1.ico" StateChanged="Window_StateChanged">
Every think work fine, if i run the application using Visual Studio 2008.But the Resource file is not created inside the Bin folder.My problem is if i copy the bin folder from this location to another location an run the exe which is created at bin the application get crashed(it seems it is searching absolute path of image)this is happen also if i move the Resource folder to another location.I have Tried to set properties of Images like this
BuilAction:Content
Copy output Directory:copy always
Now it is creating a Folder name “Resources” inside bin folder.But it is not even run the application via Visual studio.it throw an Exception says it cant find particular icon.
- Can any one explain why this is happening?
- How can i copy these Resource folder when deploy the application?Because i need my application read files from that folder at deployment environment.
- If i Set the property to embedded Resource is it possible to replace the image at
run time with another image?
Thanks in Advance:)
To reference a relative path, set your Icon Location as;
I’m not sure why your image isn’t being copied across.
I’ve just tried this, and my icon is copied into the debug directory, within the Resources Directory.
Just to be sure, are you definitely setting the “Build Action” of the Icon to “Content“, and the “Copy to output Directory” as “Copy Always“?
Also, again just to be sure… Are you including the file in the project? That is, if you set the “Show All Files” option on, if you right click on the icon, you can include it in the project.