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.
Locked
boskap
Posts: 21
Joined: Sun Jul 15, 2018 4:00 pm

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: 14480
Joined: Tue May 22, 2007 9:57 am
Contact:

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
Joined: Sun Jul 15, 2018 4:00 pm

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: 14480
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: browse folder function problem

Post by jvierra »


Locked