Example tutorials for using URIs under WPF

Source: Internet
Author: User
Background
In a WPF-developed project to use the map, the original Google map was blocked, and now use Baidu map. Baidu maps using the JavaScript API call Baidu maps application, on the WPF platform used by the Webbroswer to access, The middle involves loading the HTML file with Webbroswer.navigate, and the resource used by navigate is the URI, which accesses the resource under the current running folder, which is the resource under/bin/debug.
We can solve this problem by placing our HTML file directly under the debug file. How do I access the current running folder? Refer to Appendix 1. The problem can be solved, but when Git version control is applied to our project, Git does not put the contents of the/bin/debug file into version control by default, which means that if someone else clones our project through version control, Its project is missing HTML files, and now we have to face the problem is how to use URIs to load the resources under the relative path.
Workaround
Solution 1:
Or to access the resources under the current folder, by setting the properties of the resource, at compile time, the resource is copied to the project's/bin/debug. The specific way to do this is to add your resource to the project, then change its properties to "Copy to output directory" to "Always copy", generate the action "content", refer to
http://blog.csdn.net/yulongguiziyao/article/details/25131597
Solution 2:
With relative path access, place your resources under the project's folder and then get the ". /.. /"Access the parent directory to get. For example, add the ThirdParty folder to your project, and add the resource bmap.html I want under thirdparty in the project. I can access the resource by using the following statement:
New Uri (System.Environment.CurrentDirectory + @ "/"). /.. /thirdparty/bmap.html ", Urikind.relativeorabsolute)
System.Environemnt.CurrentDirectory is also the/bin/debug directory, through/. /.. /go back to the project directory, so the project directory under the ThirdParty directory, we can directly access to this resource, while this resource can also be released through version control, the problem can be solved.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.