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
- What resource folder are you talking about? In WPF, resources are typically embedded in the assembly file.Kris Vandermotten– Kris Vandermotten2014-06-05 09:39:24 +00:00Commented Jun 5, 2014 at 9:39
- Are you talking during development or during the running of the application...Schwarzie2478– Schwarzie24782014-06-05 09:39:35 +00:00Commented Jun 5, 2014 at 9:39
- During running of applicationbRaNdOn– bRaNdOn2014-06-05 09:41:21 +00:00Commented Jun 5, 2014 at 9:41
2 Answers
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"); 3 Comments
string file path? See my updated answer.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.