Click here to Skip to main content
15,909,091 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All,

I am running with a scenario where i need to read images from multiple folder is testApplication.
when i call
C#
Application.Current.Host.Source
then i get into the ClientBin folder on .xap file. but its an absolute path...

how to get a relative path of an image where i have following structure of folders

>TestApp.Web
   > ClientBin
      > myXap.xap
   > Images
     > testImage.png


i have tried new
"c#"
URI("SilverlightProjectName;component/Images/testImage.png". URIKind.relative)


but
"c#"
GetResourceStream()
returns null in this case too

Thanks in Advance
Posted
Comments
SASS_Shooter 11-May-12 12:36pm    
In Silverlight you are in a very small sandbox that limits your access to files.
Typically when accessing a directory for files, you are required to use the OpenFile dialog and use whatever the user selects. I do not think you can browse an entire folder grabbing files.

1 solution

You can do something like this:
C#
string actual_image = "Images/testImage.png"; //Get the relative url of your image
new Uri("SilverlightProjectName;component/"+actual_image, URIKind.relative);


If you want to use the GetResourceStream() you must right click on your image and set the Compilation Action to Resource.

Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900