So here’s the thing…
I’m making a small app that should be able to list EVERYTHING on a users Desktop – including shortcuts.
So I was doing this:
string filepath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
DirectoryInfo d = new DirectoryInfo(filepath);
foreach (var file in d.GetFiles())
{
Console.WriteLine(file.Name);
}
That gives me the following:
Spotify.lnk
Desktop.ini
But on my Desktop I can see these:
Spotify.lnk
Desktop.ini
Microsoft Office 2010
VLC Media Player
So I tried to pull some WMI info from: Win32_ShortcutFile without any luck.
(It lists stuff I don’t have on the desktop like Windows Live.)
So at the moment I’m kind of clueless…
I hope this made any sense!
Any pointers in the right direction would be awesome!
Cheers.
EDIT: I forgot to mentioned – the target node is a Windows Server 2008 SP1 machine.
EDIT: I also forgot to mention that I am already checking for folders on the desktop.
You need to check the public user’s desktop.
In .Net 4.0 and above, you can use the
Environment.SpecialFolder.CommonDesktopDirectoryspecial folder to get at that directory.On your machine it is probably
C:\Users\Public\Desktopif you have not changed it. If you look in there, you should see the files that are missing from theC:\Users\YourUserName\Desktopfolder.If you are on .net 3.5 or below, then the
CommonDesktopDirectorydoes not exist in the special folder enum. If that is the case, you will need to use a Win32 API call to get the folder path.