Hi All,
Does anybody knows how to Get the Downloads Folder Path in c11 and windows 11 64 bit
Hi All,
Does anybody knows how to Get the Downloads Folder Path in c11 and windows 11 64 bit
This may work
Command Prompt
echo %USERPROFILE%\Downloads
Powershell
(Get-ItemProperty âHKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Foldersâ).â{374DE290-123F-4565-9164-39C4925E467B}â
if you know the user profile
C:\Users\username\Downloads
Cheers
Thx ! I will give it a try
I got the environement variable C:\Users\username so it works now.
I tried SHGetKnownFolderPath
MODULE(âshell32.dllâ)
SHGetKnownFolderPath(*LPCGUID rfid, ULONG dwFlags, ULONG hToken, *ULONG ppszPath), LONG, PASCAL, RAW, NAME(âSHGetKnownFolderPathâ)
END
but couldnât get it working
I guess this is a yes, but did you add the Download folder to the environment path?
If you got the environment variable, it should work, unless the program is not running under the user and lack the permissions to write to that folder.
Yes it is working. Thx
C:\Users\username\downloads
Hi Drik,
I had Claude create a class to do this (So no RUN etc. required).
Repo is here: msarson/GetKnownFolderPathClass: Clarion class wrapping the Windows SHGetKnownFolderPath API (ANSI, 32-bit, runtime-loaded)
It dynamically loads SHGetKnownFolderPath at runtime so there is no lib required either.
I hope this help you, and anyone else needing something for this.
Usage
INCLUDE('KnownFolderPath.inc'),ONCE
FolderPath CSTRING(32767)
Folders KnownFolderPath
CODE
IF Folders.GetFolder(KnownFolderNo:Downloads, FolderPath) = KnownFolder:Success
MESSAGE(FolderPath)
ELSE
MESSAGE(Folders.LastError())
END
UPDATED FOR CLARION 12 UNICODE BETA
INCLUDE('KnownFolderPathW.inc'),ONCE
FolderPath USTRING(32767)
Folders KnownFolderPathW
CODE
IF Folders.GetFolderW(KnownFolderNo:Downloads, FolderPath) = KnownFolder:Success
MESSAGE(FolderPath)
ELSE
MESSAGE(Folders.LastError())
END
Mark
Getting the info out of the registry seems a little heavy-handed to me. Three are some files in the libsrc directory called CSIDL⌠which deal with special folders
something like downloadspath = svSpecialFolder.getdir(sv:csidl_personal)
then strip off "Documents " from the end and add âDownloadsâ
CSIDL is soooooo 2007 ![]()
Ah well, just when you find that Clarion actually provides you with a way to deal with something rather than roll your own, you find out the thing is deprecated anyway.
Thx all and specially Mark,
All solutions work. What is the most best/robust one?
FWIW, the latest version of our ProPath templates use Known Folders (they used to use CSIDL - you are SO right Jane
). Not only the Downloads folder, but all others.
ProPath makes it trivial to put your data files, INI files, etc anywhere you need them to be.
This includes data files in a shared location and local per-user files on the userâs own machine or putting some files in one location and other files in different locations.
It also supports multiple data sets with the ability to change them at startup and at runtime.
You can also open Windows Explorer directly to any folder (including the Known Folder list) to give your users easy access.
Plus you can package and deploy files to your users for startup or demo data and have them automatically put where they need to be on demand or in a âFirst Runâ scenario.
Docs here:
More info here:
https://clarionproseries.com/html/propath.html
Charles
Hi Mark Sarson,
I am using your solution. Thx. I was wondering if it also can work with the
Universal Naming Convention (UNC)?
I have a simple function to change a path to UNC
Hi Dirk,
Glad itâs useful. Yes, it works with UNC paths. The class returns whatever location Windows has for the folder and doesnât change it:
UncPath = YourToUNC(Folders.GetPath(KnownFolderNo:Documents))
GetPath(..., TRUE) works fine with UNC paths and doesnât add a second backslash. The only exception is KnownFolderFlag:DefaultPath, which ignores redirection and always returns the default local location.
Great, thanks again