Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test for "My Documents" folder redirection

Is it possible to test for folder redirection in .net? I don't mean reparse points/junctions, I mean when a folder (usually My Documents) is redirected to a server.

In such cases, if you are traversing the folder system of a PC you'll encounter an IO error if you reach the local version of the folder. So it would be useful to be able to test for My Documents folder redirection, so as to be able to take action (skip the folder, jump onto the server etc).

I know I can get the location of My Documents (but only for the current user) using Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) but that doesn't help me test for it in advance across (potentially) multiple users.

Do I need to use something like SHGetKnownFolderPath?

like image 911
hawbsl Avatar asked Feb 08 '10 07:02

hawbsl


People also ask

How do I redirect My Documents folder to server?

Right-click a folder that you want to redirect (for example, Documents), and then select Properties. In the Properties dialog box, from the Setting box, select Basic - Redirect everyone's folder to the same location.

Is Folder Redirection a good idea?

Folder Redirection allows saving data regardless of storage location and separates user data from profile data decreasing the time required to log on. Other advantages include: Data is stored on a server where it can be backed up.

Where can you find Folder Redirection?

Open User Configuration > Policies > Windows Settings > Folder Redirection. Right-click Documents and click Properties. Choose Basic - Redirect everyone's folder to the same location.


1 Answers

You could query the registry key:

http://support.microsoft.com/kb/221837

You can also query the group policy for redirection:

http://technet.microsoft.com/en-us/library/cc781907(WS.10).aspx

Once you have that value you can easly test for network/mapped drive, this is how I do it.

like image 120
James Campbell Avatar answered Sep 22 '22 09:09

James Campbell