browse folder function problem

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
boskap
Posts: 21
Last visit: Sun Oct 21, 2018 4:24 am

browse folder function problem

Post by boskap »

hello
Sorry my english is not so good

i have a question / problem with the browse folder function
when i choose a folder and set a variable with this folder , adding a subfolder the path is ok

$Back_Rec_Path = $folderbrowserdialog2.SelectedPath
$global:DestPath = $Back_Rec_Path + "\BACKUP\" + $Env:USERNAME # zb.: C:\Backup\Username...

the $destpath variabe is then ok, like d:\test\backup\

but when i choose a root drive like d:\ the $destpath is d:\\backup
now i have to backslash

what i make wrong
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: browse folder function problem

Post by jvierra »

The following is a safe way to join multiple path segments.

$global:DestPath = [system.io.path]::Combine($Back_Rec_Path.'BACKUP',$Env:USERNAME)
boskap
Posts: 21
Last visit: Sun Oct 21, 2018 4:24 am

Re: browse folder function problem

Post by boskap »

hi
thx

But can you explain what this line means
what means system.io.path

$global:DestPath = [system.io.path]::Combine($Back_Rec_Path.'BACKUP',$Env:USERNAME)

thx for your support
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: browse folder function problem

Post by jvierra »

This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked