You are here:

C#/Full address of a user's Desktop

Advertisement


Miguel Sierra wrote at 2007-06-19 11:06:07
I found a problem like you, but I Find a solution, maybe not the best, but this works perfectly.

The problem with this kind of paths is that they can be changed in active directory.

The solution is to find the desktop path in the registry, first we must find the localuser desktop but if this is null we will find the all users desktop registry entry. Is important to be sure that we have permision to access to that path. Here is the code:







Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine;

         key = key.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");

         try

         {

         Desktop = key.GetValue("Desktop").ToString();

         this.Mensajes.Items.Add("Se ubicó en el escritorio el " + nombrecertificado + ".PDF");

         

         }

         catch

         {

         Desktop = key.GetValue("Common Desktop").ToString();

         this.Mensajes.Items.Add("Se ubicó en el escritorio común el " + nombrecertificado + ".PDF");

         

         }



Try it!



Miguel Sierra Sánchez

Cic Consulting Informático




onSlaught wrote at 2007-11-13 23:10:22
Try: (C# Code)

string path = System.IO.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory)


C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Srini Nagarajan

Expertise

can answer any kind of questions in ASP.NET, C#, VB.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase

Experience

Contact me if you need any custom development on ASP.NET, ASP, Coldfusion, Powerbuilder

©2012 About.com, a part of The New York Times Company. All rights reserved.