Permission "Environment.SpecialFolder.Personal" with active folder redirection

By default, Windows Forms saves data files in the My Documents folder (in XP) or the Documents folder (in Vista). We look at this location, calling:

Environment.GetFolderPath( Environment.SpecialFolder.Personal ) 

We know for sure that this works great for users whose personal folder is on the local drive. We are not sure that domain users who have folder redirection act for their folders with profile / personal data.

My question is: Is the above call resolved correctly regardless of whether folder redirection is active?

I do not have the environment to verify this, and I could not find any specific evidence anyway.

+4
source share
3 answers

Yes Yes. You can verify this yourself by updating the appropriate registry entry for this folder. Look under ...

HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Shell Folders

+1
source

I would expect it to be so. The documentation for Environment.GetFolderPath and the underlying SHGetSpecialFolderPath does not give any indication that it will not be fixed correctly, and I cannot find anything that you will use your place.

+1
source

I know that this has been a while, but I would like to report here that I had a user reporting the following error in calling Environment.GetFolderPath (Environment.SpecialFolder.Personal) on an XP computer whose documents are being redirected to the network (goes to drive O):

 System.ArgumentException: Absolute path information is required. at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path) at System.Environment.GetFolderPath(SpecialFolder folder, SpecialFolderOption option) at System.Environment.GetFolderPath(SpecialFolder folder) 

I did not have direct access to this machine configuration yet, but from Google search and user help, I believe that the redirect does not have the final \ (for example, O: instead of O: \).

So, I believe that the answer will be no, it will not be correctly resolved every time .

+1
source

All Articles