I use VS2010 to create a setup project, I have a custom action which should create a file in My Documents folder.
But Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
returns me an incorrect value. My Documents folder was redirected to another folder in D: drive.
When I test the custom action, I fount this method returns me an empty value, but it could return me a correct value in console applications, can anyone help?
Custom actions in VS setup projects that are being installed for Everyone run with the system account, not the account of the installing user.
If you want to create a file in that Documents folder, pass the PersonalFolder standard Windows Installer property into your custom action.
http://msdn.microsoft.com/en-us/library/aa370905(v=vs.85).aspx#system_folder_properties
If it's a installer class call I think you'd pass it iss one of the calling argument in the form:
/mydocs=[PersonalFolder]
then use the dictionary key [arg] to get the actual resolved value (that's what [] means).