how to set image file path in app config file?
I have a console application and it has a folder images in it.
How can I set path i开发者_StackOverflow社区n the app.config file similar to below:
~/images/logo.jpg
../images/logo.jpg
Use System.IO.Path.Combine method to combine a base path with a relative path like:
System.IO.Path.Combine(Environment.CurrentDirectory, relativePath);
Environment.CurrentDirectory in the above line with whatever base path you want.
Are you asking how to add those file names to the app.config?
if so...
<appSettings>
<add key="image1" value="~/images/logo.jpg"/>
</appSettings>
This can be read by adding a reference to System.Configurations
And then calling ConfigurationManager.AppSettings["image1"]
;
You can access any value in the app.config using the Configuration manager.
精彩评论