Reputation: 67
I loaded image for a click event. For another event i need to get path of loaded image here's my code for loading image
Image img = new Image();
Stream imageStreamSource = new FileStream("img/block.png", FileMode.Open, FileAccess.Read, FileShare.Read);
PngBitmapDecoder decoder = new PngBitmapDecoder(imageStreamSource,BitmapCreateOptions.PreservePixelFormat,BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];
ImageSource imageSource = bitmapSource;
img.Source = imageSource
Is there any way to get path of img as string value or different?? Because i want to compare it's path for other event
Upvotes: 0
Views: 257
Reputation: 2741
You can try casting to FileStream to get full path
FileStream fStream = imageStreamSource as FileStream;
var filePath = fStream.Name;
Upvotes: 1