Solved

WPF C# - what path is  URI point to

Posted on 2013-06-18
5
425 Views
Last Modified: 2013-07-04
new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "Images/icon.png")))

Where should I put the icon.png?

I thought I should put the icon.png into /application/Images/icon.png where the application (Executeable) is running from /application
0
Comment
Question by:tommym121
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:QPR
ID: 39258339
0
 

Author Comment

by:tommym121
ID: 39259448
This is my line

            Brush brsh = new ImageBrush(new BitmapImage(new Uri("Images//WLM-icon.png")));
It cause an exception on Uri()


            new Uri("Images//WLM-icon.png")      This expression causes side effects and will not be evaluated      System.Uri


I put the image file in this directory
C:\Users\user1\Documents\Visual Studio 2010\Projects\TestWPF\TestWPF\bin\Debug\Images

I am not sure what"s go wrong.  Can someone help?
0
 
LVL 13

Accepted Solution

by:
jonnidip earned 500 total points
ID: 39290130
You better create a Solution Folder (for example: "Icons") in your project and put your images there.
You may then reach your folder this way:
new Uri("pack://application:,,,/<yourProjectName>;component/Icons/WLM-icon.png")

Open in new window


I hope this helps.

Regards.
0
 

Author Closing Comment

by:tommym121
ID: 39300372
Thanks
0
 
LVL 13

Expert Comment

by:jonnidip
ID: 39300385
You're welcome!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question