Page view counter

Silverlight Tips of the Day - Blog by Mike Snow

Game Programming with Silverlight

Silverlight Tip of the Day #97 – How to get an Image’s Source File Name

Once you have an image loaded how do you go back and get the original file name for the source file?

This can be accomplished through the Uri property of the images Source. However, you must first typecast the images Source to be a BitmapImage. The Uri has a property called OriginalString that returns the full relative path to the image file.

Example:

public string GetImageSourceFile(Image img) 
{ 
    BitmapImage bi = (BitmapImage) img.Source; 
    Uri uri = bi.UriSource; 
 
    return uri.OriginalString 
}

Thank you,
--Mike Snow

 Subscribe in a reader

Comments

Microsoft Weblogs said:

Once you have an image loaded how do you go back and get the original file name for the source file?

# February 28, 2009 5:11 PM

Community Blogs said:

In this issue: Mark Monster, Jesse Liberty, Eric Mork, Mike Snow, Jeff Weber, Bob Brumfield and Erwin

# March 1, 2009 2:23 AM

cxhsoft said:

thanks !

# March 1, 2009 8:13 PM

cxhsoft said:

thanks!

# March 1, 2009 8:14 PM

Visual Web Developer Team Blog said:

Most Recent Posts: Silverlight Tip of the Day #106 - Setting Default Browser from within VS Silverlight

# April 6, 2009 6:13 PM

Silverlight Tips of the Day - Blog by Mike Snow said:

The purpose of this post is to create an outline summary all the blogs from my Silverlight Tips of the

# April 6, 2009 6:20 PM

NewsPeeps said:

Thank you for submitting this cool story - Trackback from NewsPeeps

# August 8, 2009 6:36 PM