Link to home
Start Free TrialLog in
Avatar of John Porter
John PorterFlag for United States of America

asked on

Access a folder on generic user's Windows Desktop using C#

Hello Experts,

I am accessing a folder on the user's Windows Desktop like this:
string strObsFile1 = @"C:\Documents and Settings\Tom\Desktop\My Folder\MyFile.exe

This works fine for the user "Tom" but I would like the string to be  generic way so the it does not matter which user is logged on...

I tried this but it did not work:
string strObsFile1 = @"C:\Documents and Settings\%User%\Desktop\My Folder\MyFile.exe

Does anyone know how to do this?

Thanks!

ASKER CERTIFIED SOLUTION
Avatar of Dustin_Loftis
Dustin_Loftis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can run a "SET" in a command line to see all the environment variables.
Avatar of John Porter

ASKER

Thanks!