0

I have this little array that is supposed to output every folder lets say. It will output just the regualar $folder[$i] but when it is in a file path it does not work. The [$i] parameter is not active. Just looking for the right syntax.

$folder = @("CloudSync", "Contacts", "Desktop", "Downloads", "Dropbox", 
"Favorites", "Links", "Documents", "Pictures", "Videos", "Searches", 
"SyncedFolder")

for ($i=0; $i -lt $folder.length; $i++)
{
echo c:\admin\$folder[$i]"<<<< problem here" $folder[$i]
}

Just outputs c:\admin\CloudSync Contacts Desktop Downloads Dropbox Favorites Links Documents Pictures Videos Searches SyncedFolder $i CloudSync

Apodolsky
  • 3
  • 1

1 Answers1

2

You have to use a sub-expression to make sure your variable expands as you want to:

"c:\admin\$($folder[$i])"
sodawillow
  • 12,497
  • 4
  • 34
  • 44