We can retrieve the paths to 'special folders', such as documents / desktops etc. The way to get the path to the 'Downloads' folder, but it seems that this is not particularly.
I know that I can only do 'C: \ Users \ Username \ Downloads', but this is an ugly solution. So how can I withdraw the path using the net?
Yes it is special, searching for the name of this folder was not possible until Vista. The pre-operating system needs to be supported. The solution is not very good but it should work reasonably well:
using the system.Runtman.Interop Services; Using System.IO; ... public static string GetDownloadsPath () {string path = null; If (Environmental. OSVersion.Version.Major & gt; = 6) {IntPtr pathPtr; Int HR = SHGTKNo Folder Path (Ref Folds Downloads, 0, Interpit Zero, Outpout Pete); If (hr == 0) {path = martial.prraststrangioni (pathpets); Marshal.FreeCoTaskMem (pathPtr); return path; }} Path = path.gate directory name (environment. Gatefolder path (environment specialfolder personal)); Path = path. Cobain (route, "download"); return path; } Private Static Guid FolderDownloads = New Guid ("374DE290-123F-4565-9164-39C4925E467B"); [DllImport ("shell32.dll", Charset = Charset.auto)] Private static extern int SHGetKnownFolderPath (Ref good ID, int flag, IntPtr token, IntPtr path out);
Feel free to tweet the Fallback version, I do not know how true this is, hopefully you will never need it.
Comments
Post a Comment