Our Windows Forms application by default saves data files in a user's 'My Documents' folder (on XP) or 'Documents' folder (on Vista). We look up this location by calling:
Environment.GetFolderPath( Environment.SpecialFolder.Personal )
We know for sure this works great for users whose personal folder is on a local disk. What we're not sure about is domain users who have Folder Redirection in effect for their profile/personal data folders.
My question is: Does the above call properly resolve regardless of whether Folder Redirection is active?
I don't have the environment to test this out, and I haven't been able to find any definite confirmation one way or the other.
Yes it does. You can test this out yourself by updating the corresponding registry entry for the folder. Look under ...
\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\
I've had a user reporting the following error on an Environment.GetFolderPath(Environment.SpecialFolder.Personal)
call on an XP machine whose My Documents is redirected to the network (it 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 haven't had direct access to this machine configuration yet, but from google searches and the user's help, I believe the redirect is lacking a trailing \ (eg. O: instead of O:\).
So I believe the answer would be no, it doesn't correctly resolve everytime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With