Is it safe to programmatically reference the public folder through:
Directory = System.Environment.GetEnvironmentVariable(\"public\")+\"MyCompanyName\" // et
Notice that the Environment.SpecialFolder.CommonDesktopDirectory is only available in .NET 4.0. For my .NET 3.5 systems (Windows 7 or XP) I used the registry key for the Shell Folders. My code snippet is in VB.NET.
Private mRegShellPath="Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
Private mCommonDesktop = Nothing
' dgp rev 3/8/2012
Private ReadOnly Property CommonDesktop As String
Get
If mCommonDesktop Is Nothing Then
Dim RegKey As RegistryKey
Try
RegKey = Registry.LocalMachine.OpenSubKey(mRegShellPath, False)
mCommonDesktop = RegKey.GetValue("Common Desktop")
Catch ex As Exception
mCommonDesktop = ""
End Try
End If
Return mCommonDesktop
End Get
End Property