Rate this:
See more:
```Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
//dlg.FileName = "Document";
//dlg.DefaultExt = ".txt";
dlg.Filter = "jpg files (*.jpg)|*.jpg|gif files (*.gif)|*.gif|jpeg files (*.jpeg)|*.jpeg";
if(dlg.ShowDialog()==true)
{
var fileName = System.IO.Path.GetFileName(dlg.FileName);
textBox4.Text=fileName.ToString();
//var path = System.IO.Path.Combine(HttpContext.Current.Server.MapPath("/Images/"), fileName);
BitmapImage src = new BitmapImage();
src.BeginInit();
src.UriSource = new Uri(textBox4.Text.Trim(), UriKind.Relative);
src.EndInit();
image1.Source = src;```
the error shows
Could not find file 'c:\users\chinmaya\documents\visual studio 2010\Projects\WpfApplication5\WpfApplication5\bin\Debug\Chrysanthemum.jpg'.
Posted 29-Sep-12 2:15am
Edited 29-Sep-12 2:18am
v3

Rate this:

## Solution 1

You have defined:
`src.UriSource = new Uri(textBox4.Text.Trim(), UriKind.Relative);`
Based on that, the filepath formed is pointing to your Bin/Debug folder.

Based on the error, it looks like the image is not placed in Bin/Debug/ folder. You need to make sure that the path is correct.

Have a defined image folder where you keep the images. If inserted, place the image there. At the time of picking it up for showing/editing, use the folder path (fixed and known by you) along with the filename to display.
chinmaya parija1 at 1-Oct-12 0:59am

var path = System.IO.Path.Combine(HttpContext.Current.Server.MapPath("/Images/"), fileName);
it is not working.
Rate this:

## Solution 2

first a folder name(image) in your project inside Bin->Debug folder
```Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.Filter = "jpg files (*.jpg)|*.jpg|gif files (*.gif)|*.gif|jpeg files (*.jpeg)|*.jpeg";
if (dlg.ShowDialog() == true)
{

if (!File.Exists(dlg.FileName))
{
var fileName = System.IO.Path.GetFileName(dlg.FileName);
textBox4.Text = fileName.ToString();
image1.Source = new BitmapImage(new Uri(dlg.FileName, UriKind.Absolute));
File.Copy(dlg.FileName, System.IO.Path.Combine(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "image"), System.IO.Path.GetFileName(dlg.FileName)));
}
else
}```
v4