Forum Discussion

smskrishna's avatar
smskrishna
Occasional Contributor
14 years ago

Path of "Local settings/Application Data" folder in Testcomplete 6.5?

Hi,



I have to get the path "C:\Documents and Settings\[username]\Local Settings\Application Data"



as part of my test case. I am using Testcomplete 6.5;C# project, Windows: XP



I have tried the follwoing option




var WshShell = Sys.OleObject("WScript.Shell");


WshShell = .OleObject("WScript.Shell");

var OutputDirectory = WshShell.ExpandEnvironmentStrings(%APPDATA%);



It returns  path as "C:\Documents and Settings\[username]\Application Data"



But I need path "C:\Documents and Settings\[username]\Local Settings\Application Data"      (Application data under local settings)



please let me know the steps to get the above path




OutputDirectory = WshShell.ExpandEnvironmentStrings(%APPDATA%);It returns  path as "C:\Documents and Settings\[username]\Application Data"But I need path "C:\Documents and Settings\[username]\Local Settings\Application Data"      (Application data under local settings)please let me know the steps to get the above path


3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Siva,



    One of the simplest option may be:

    OutputDirectory = aqFileSystem.ExpandUNCFileName(OutputDirectory + "\..\Local Settings\Application Data")
  • smskrishna's avatar
    smskrishna
    Occasional Contributor
    Hi Alexei,



    Thanks for the reply.



    This will not solve my problem because, I have to use the same test case in German OS also. So I cannot hard code value like "Local Settings" which is different in German OS.



    So I am using the following to solve the issue



    outputdirectory=dotNET["System"]["Environment"]["GetFolderPath"](dotNET["System"]["SpecialFolder"]["LocalApplicationData"])

  • Hi Siva,




    Also, you can try using the following script that does not require .NET installed: 




     

    function Test()


    {


      // Define a variable to be passed as the Shell.NameSpace method's parameter.


      // For additional information, see the "ShellSpecialFolderConstants Enumeration" MSDN article.


      var ssfLOCALAPPDATA = 0x1c;


      var oShell = new ActiveXObject("Shell.Application");


      var OutputDirectory = oShell.NameSpace(ssfLOCALAPPDATA).Self.Path;


      Log.Message(OutputDirectory); 


    }