On my machine, it’s here:
string downloadsPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Downloads");
But on a colleagues machine, this folder doesnt exist, and his Downloads folder is in his ‘My Documents’ folder. We are both on Windows 7*.
*Edit: in fact, it turns out he was not running the app on his own machine but a Windows Server 2003 machine.
Windows does not define a CSIDL for the Downloads folder and it is not available through the
Environment.SpecialFolderenumeration.However, the new Vista Known Folder API does define it with the ID of
FOLDERID_Downloads. Probably the easiest way to obtain the actual value is to P/invokeSHGetKnownFolderPath.Note that the P/invoke given on pinvoke.net is incorrect since it fails to use Unicode character set. Also I have taken advantage of the fact that this API returns memory allocated by the COM allocator. The default marshalling of the P/invoke above is to free the returned memory with
CoTaskMemFreewhich is perfect for our needs.Be careful that this is a Vista and up API and do not attempt to call it on XP/2003 or lower.