Reputation: 3803
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.
Upvotes: 5
Views: 5116
Reputation: 377
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.
Upvotes: 2
Reputation: 754715
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\
Upvotes: 3
Reputation: 3009
I would expect that it does. The documentation for both Environment.GetFolderPath
and the underlying SHGetSpecialFolderPath
don't give any indication that it would not resolve correctly nor can I find anything that you would use its place.
Upvotes: 1