简体   繁体   中英

file Path not picking in vb.net

I have an existing file and included in project under Templates folder, I am trying to open it using below code but its giving me an error "File not found"

oDoc = oWord.Documents.Open("\Templates\TestTemplate.docx")

please advise how to pass the file available under project

Use Code:

oDoc = oWord.Documents.Open("..\Templates\TestTemplate.docx")

Explanation:

Your exe will be under bin->debug/release folder. This '..\\' is used to point one step backward in the path.

Say for example, if your 'Templates' folder is found in the folder where your 'bin' folder is placed.Then you can get the path by giving the above piece of code.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM