I am attempting to copy a selected image to a folder and then want to display it with an Image object. The copying works fine, but when I want to display it it seems like the program cannot find it. Displaying the image only works if I manually use "add existing Item". Is there a way to add it automatically?
Here is my code:
string name = "image1";
OpenFileDialog dialog = new OpenFileDialog();
Nullable<bool> dialogOK = dialog.ShowDialog();
if(dialogOK == true)
{
File.Copy(dialog.FileName, @"..\..\Images\" + name + ".png", true);
image.Source = new BitmapImage(new Uri(@"Images\" + name + ".png", UriKind.Relative));
}
("image" is defined in xaml)