John Porter
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!
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
Does anyone know how to do this?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can run a "SET" in a command line to see all the environment variables.
ASKER
Thanks!