1. Luis Pesaressi
  2. PowerBuilder
  3. Thursday, 12 September 2024 04:19 AM UTC

Hello everyone,

do you know how I can get the path of the Windows user's documents directory, regardless of the language configured in the Operating System (Window)?

 

Thanks

 

Luis

mike S Accepted Answer Pending Moderation
  1. Thursday, 12 September 2024 11:49 AM UTC
  2. PowerBuilder
  3. # 1

Get the users' directory first with GetContextKeywords: 

ls_envkey = "%userprofile%"

or

ls_envkey = "%HOMEPATH%"

 

ContextKeyword icntext_keyword

icntext_keyword.GetContextKeywords(ls_envkey, ls_values[])

then append the subdirectory you want to use:


ls_values[1] + "\Documents"

 which is exactly what you don't want to do since it is locale dependent. 

It is weird that windows has all of these %values% but not one for documents.  

 

 windows - Is There A System Defined Environment Variable For Documents Directory? - Stack Overflow

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 12 September 2024 05:25 AM UTC
  2. PowerBuilder
  3. # 2

You can use the windows api function SHGetFolderPathW with folder code (csidl) 5.

In PFCs platform service you can find the function of_GetKnownFolderPath as a codes example how to use the function.

https://github.com/OpenSourcePFCLibraries/2022/blob/main/ws_objects/pfcapsrv/pfcapsrv.pbl.src/pfc_n_cst_platformunicode.sru

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.