Author Topic: How does SE find the Windows Documents folder?  (Read 523 times)

ebbe

  • Community Member
  • Posts: 45
  • Hero Points: 2
How does SE find the Windows Documents folder?
« on: June 01, 2023, 08:26:19 AM »
In the good old days there was only one Documents folder, found in C:\users\username\Documents.

But with Windows 11, that folder may be located in OneDrive and that is the one SE will use. Since I quite often have multiple instances of SE open (one for target code and one for PC code), I usually run SE with the -x option that refers to a project specific vslick.sta. I also have a utility, that will update the local copy with the one found in ...\username\Documents\My SlickEdit Config\21.0.2 - and this utility now fails, because that folder does not exist. So, I want to know how SE determines where to put its config files such that I can mimic that in my own utility.

BTW: the Help file entry for Options -> Application Options -> Exit -> Save configuration does not describe all the choices for this item. Specifically the one named "Share config - Save configuration immediately" is not described.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6866
  • Hero Points: 528
Re: How does SE find the Windows Documents folder?
« Reply #1 on: June 01, 2023, 01:33:21 PM »
Thanks for noticing that the docs for "Share config - Save configuration immediately" is missing.

This roughly the code SlickEdit uses to get the config path on Windows:

Code: [Select]
      // For v27 and before, code looks like this:
      hrstatus = SHGetSpecialFolderLocation(0,CSIDL_PERSONAL,&pidl);
      if( hrstatus==NOERROR ) {
         wchar_t tempsw[CMMAXFILENAME];
          hrstatus=SHGetPathFromIDListW(pidl,tempsw);

          // Now append My SlickEdit Config\SlickEdit\27.0.2\

          // End up with something like this:
          // C:\Users\<username>\Documents\My SlickEdit Config\27.0.2



      //Due to customers having problems with the above default location due to OneDrive I/O
      // v28 will do this instead:
      hrstatus = SHGetSpecialFolderLocation(0,CSIDL_LOCAL_APPDATA,&pidl);
      if( hrstatus==NOERROR ) {
         wchar_t tempsw[CMMAXFILENAME];
          hrstatus=SHGetPathFromIDListW(pidl,tempsw);

          // Now append SlickEdit\28.0.0\

          // End up with something like this:
          // C:\Users\<username>\AppData\Local\SlickEdit\28.0.0\>


It may be easier to use the "-sc <configpath>" option to force SlickEdit to use a configuration directory you specify.

ebbe

  • Community Member
  • Posts: 45
  • Hero Points: 2
Re: How does SE find the Windows Documents folder?
« Reply #2 on: June 02, 2023, 06:14:53 AM »
This roughly the code SlickEdit uses to get the config path on Windows:

Thanks. It's working now.

Code: [Select]
      //Due to customers having problems with the above default location due to OneDrive I/O
      // v28 will do this instead:
      hrstatus = SHGetSpecialFolderLocation(0,CSIDL_LOCAL_APPDATA,&pidl);
      if( hrstatus==NOERROR ) {
         wchar_t tempsw[CMMAXFILENAME];
          hrstatus=SHGetPathFromIDListW(pidl,tempsw);

          // Now append SlickEdit\28.0.0\

          // End up with something like this:
          // C:\Users\<username>\AppData\Local\SlickEdit\28.0.0\>


And thanks for the heads-up. I'll keep that in mind.

It may be easier to use the "-sc <configpath>" option to force SlickEdit to use a configuration directory you specify.

I'll take a look at that. However, my current solution works for me.