Getting Downloads Folder in C#? [duplicate]
The WinAPI method is the only correct way to retrieve paths to special folders - including the personal ones and the Downloads folder.
There are other ways to get similar results which look promising, but end up with just completely wrong paths on specific systems (for example, combining or hard coding parts of the path or abusing an old registry key). The reason behind that is stated in my CodeProject article, which also lists the full solution. It provides a wrapping class with a support of retrieving all known 94 special folders, and some more goodies.
For a quick example here, I just pasted a shortened version of the solution, being able to retrieve only the personal special folders, like Downloads:
(A fully commented version is found in the CodeProject article linked above.)
While this was just a nasty wall of code, the surface you have to deal with is pretty simple. Here's an example of a console program outputting the path of the Downloads folder.
E.g., just call with the enum value of the folder which path you want to query.
NuGet Package
If you don't want to go through all this hazzle, just install my NuGet package I recently created. Here's the project site, and here's the gallery link (note that the usage is different and polished, please consult the Usage section on the project site for more information).
Usage:
-
-
-