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

0

1 Answer 1

2

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

"c:\admin\$($folder[$i])"
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much! it works!
You're welcome. Click the green check mark near the votes if you wish to accept the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.