2
Answers

setting the imagesource

bodnar edmond

bodnar edmond

15y
7.5k
1
hi, i am trying to set an image source without giving the full path. It works only with this code:
Uri uri = new Uri("C:/Documents and Settings/user/My Documents/Visual Studio 2008/Projects/player/poze/open1.jpg");
ImageSource imgSource = new System.Windows.Media.Imaging.BitmapImage(uri);
img_open.SetValue(Image.SourceProperty, imgSource);

But, if i try to run the application on other computers, it doesn't load the image, and it's obvious.

i tried to do somethig like this:
System.Environment.CurrentDirectory = "C:/Documents and Settings/user/My Documents/Visual Studio 2008/Projects/player/poze/";
and then run the code:
Uri uri = new Uri("open2.jpg",UriKind.Relative);
ImageSource imgSource = new System.Windows.Media.Imaging.BitmapImage(uri);
img_open.SetValue(Image.SourceProperty, imgSource);
but it doesn't work.
any suggestions?
Answers (2)
0
Suthish Nair
NA 31.7k 4.6m 14y
Is this query got resolved?
0
Sam Hobbs
NA 28.7k 1.3m 14y

Maybe you can clarify this for me; I'm a lot confused about your question.