ScottishTapWater
ScottishTapWater

Reputation: 4776

File Path Variables

I can't work out (even after a fair bit of research) how I can can set a file path in VB to point towards the desktop of the current user, regardless of what their username is. Currently, my only efforts have required hardcoding that part of the path and this is really hampering the development so any help would be greatly appreciated, my current code segment is below.

FileCopy(photoJobs(lastJob).imagePath, "C:/Users/James/Desktop/Backup Jobs/" & lastJob & Strings.Right((photoJobs(lastJob).imagePath), 4))

Which just copies the file pointed to by the first part (this bit works) to the desktop held folder, backup jobs, and renames them, it's this second part that needs changing.

Thanks in advance!

Upvotes: 1

Views: 52

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564333

You should use Environment.GetFolderPath(Environment.SpecialFolder.Desktop) to retrieve the current user's desktop folder.

Upvotes: 1

Related Questions