简体   繁体   中英

Relative path in VB.Net

i searched for this but found nothing relevant to me.

in VB.NET , i have a String var called PDF_Path . i want to insert into PDF_Path the path of the GuideLine.PDF file that i have in the visual studio project .

my project tree in visual studio :

 Solution 'XML Slave'(1 project)
 XML SLAVE
    |______(FOLDER)docs
           |______**GuideLine.PDF** 
    |______(FOLDER)Images
    |______(FOLDER)Resources
    |______about.vb
    |______MainForm.vb
    |______MsgForm.vb

the GuideLine.PDF file is in "docs" folder . how i can get the path of the file in visual studio and insert the path into String PDF_Path variable ?

Use the My namespace to access quick and handy features, likeDirectoryPath

Dim PDF_Path = System.IO.Path.Combine(My.Application.Info.DirectoryPath, "\docs\GuideLine.PDF")

Also remember to set the Copy To Output Directory property to Copy always, just to be sure that the file will be available in the executing working folder of the app.

TIP: Do not put underscore chars in your variable identifiers, just use the globally accepted lower camelCase style for local vars.

Dim pdfPath

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