1

is there a way to get the dynamic path of a resources folder in wpf application?? im currently searching for the solution for this matter but i cant find any article with regards on this matter

3
  • What resource folder are you talking about? In WPF, resources are typically embedded in the assembly file. Commented Jun 5, 2014 at 9:39
  • Are you talking during development or during the running of the application... Commented Jun 5, 2014 at 9:39
  • During running of application Commented Jun 5, 2014 at 9:41

2 Answers 2

8

You can find the full file path of the actual executing assembly using this line:

string appFolderPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); 

Getting the path of your Resources folder from there shouldn't be hard... if I had know where you added it, I could have helped further. If you added it into the root directory of the project, then you should be able to access the correct file path doing something like this:

using System.IO; ... string resourcesFolderPath = Path.Combine( Directory.GetParent(appFolderPath).Parent.FullName, "Resources"); 
Sign up to request clarification or add additional context in comments.

3 Comments

the output of this code is in debug folder is there another way to locate it dynamically?
Really? You don't know how to manipulate a string file path? See my updated answer.
I will test it on installed application in my computer hope it didnt get any errors like it did before
1

All situations where you need to find things based on the running application, normaly I would look at reflection.

Say you want the folder below your executable, I would call something like

System.Reflection.Assembly.GetExecutingAssembly().Location 

to determine where you are running and exend that path to go to a relative subpath.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.