How to get programmatically the number of AppData\Roaming\SDL\ProjectApi folder?

I'm checking Studio 2019 SR2 and found that my code for getting the real default project template is failing...
It's failing because Studio 2019 screwed the folders numbering system which worked for years... Disappointed

So far the numbering system was simple and consistent:

    "Studio2"  {$StudioVersionAppData = "10.0.0.0"}
    "Studio3"  {$StudioVersionAppData = "11.0.0.0"}
    "Studio4"  {$StudioVersionAppData = "12.0.0.0"}
    "Studio5"  {$StudioVersionAppData = "14.0.0.0"}
    "Studio15" {$StudioVersionAppData = "15.0.0.0"}

But now I see that Studio 2019 SR1 - and also SR2 - has AppData\Roaming\SDL\ProjectApi\15.1.0.0 folder :-O :-O :-O

That number does not correspond to anything...
All other such numbered folders have 15.0.0.0 number.
SDLTradosStudio.exe product version is 15.0.0.0, file version is 15.2.0.1041.

So, where does this weird number come from and how do I get it programmatically, please?!
Of course I need it to work 100% realiably across ALL Studio versions, SRs and CUs.

Ultimately, I need to read the AppData\Roaming\ProjectApi\<number>\Sdl.ProjectApi.xml file, so if there is any other way to get its full path, I'm fine with that way too.

Parents
  • Hi,

      We have noticed that the folder name is probably identical to the dll version number of the ProjectApi.dll file in the Studio install directory, so we use the following code to get this value:

    var StudioInstallPath = ... // get this programmatically
    var StudioProjectApiVersion = System.Reflection.AssemblyName.GetAssemblyName(System.IO.Path.Combine(StudioInstallPath, "Sdl.ProjectApi.dll")).Version.ToString();

      So far it has returned the correct path for the ProjectApi subfolder.

    Attila

    EDIT: Previously I used the default installation path for Studio for example's sake, but of course it should be obtained programmatically!

Reply
  • Hi,

      We have noticed that the folder name is probably identical to the dll version number of the ProjectApi.dll file in the Studio install directory, so we use the following code to get this value:

    var StudioInstallPath = ... // get this programmatically
    var StudioProjectApiVersion = System.Reflection.AssemblyName.GetAssemblyName(System.IO.Path.Combine(StudioInstallPath, "Sdl.ProjectApi.dll")).Version.ToString();

      So far it has returned the correct path for the ProjectApi subfolder.

    Attila

    EDIT: Previously I used the default installation path for Studio for example's sake, but of course it should be obtained programmatically!

Children
  • That's surely interesting discovery, but now we need 100% sure confirmation from SDL side that it not only IS true right now, but also WILL BE true in the future.

    EDIT:
    And BTW, don't do the same mistake as SDL does for example in the above mentioned SDL FreshStart - hardcoding paths.
    It's NEVER set to stone that Windows will be installed on a C: drive and that the directories will be named as they usually are! Such paths MUST ALWAYS be obtained programmatically!