Jump to content

Recommended Posts

Posted

Fixed it... feel free to lock the thread.

 

I am trying to write a launcher application (just for fun) however whenever I try to load the background from a file the application wont open (line 3 is the cause of the issue).

My code is:

var BackgroundDirectory = System.IO.Path.Combine(Directory.GetCurrentDirectory(),"\\Background.png");
            this.Title = ConfigurationManager.AppSettings["WindowName"];
            this.Background = new ImageBrush(new BitmapImage(new Uri(BackgroundDirectory)));

and I have placed Background.png in the release folder (configuration is set to release). Any help would be majorly appreciated!

 

Solution:

var BackgroundDirectory = System.IO.Path.Combine(Directory.GetCurrentDirectory(),"Background.png");
            this.Title = ConfigurationManager.AppSettings["WindowName"];
            this.Background = new ImageBrush(new BitmapImage(new Uri(BackgroundDirectory)));

should work however I chose to just use strings instead... 

string BackgroundDirectory = Directory.GetCurrentDirectory + "//Background.png"

 

Posted
1 hour ago, PhenomenalDev said:

Fixed it... feel free to lock the thread.

 

I am trying to write a launcher application (just for fun) however whenever I try to load the background from a file the application wont open (line 3 is the cause of the issue).

My code is:


var BackgroundDirectory = System.IO.Path.Combine(Directory.GetCurrentDirectory(),"\\Background.png");
            this.Title = ConfigurationManager.AppSettings["WindowName"];
            this.Background = new ImageBrush(new BitmapImage(new Uri(BackgroundDirectory)));

and I have placed Background.png in the release folder (configuration is set to release). Any help would be majorly appreciated!

You should actually provide the solution if you figured it out.

Posted
9 minutes ago, panda said:

You should actually provide the solution if you figured it out.

Will update the thread, it was literally just because I misunderstood path.combine.

Guest
This topic is now closed to further replies.
×
×
  • Create New...