Forum Discussion

Manfred_F's avatar
Manfred_F
Regular Contributor
10 years ago
Solved

file object, properties & methods

Hi,

for the file object in the files collection, there is only a check method, no properties are defined.

I wonder why.

I'd like to Access a file's path, text (for Textfiles) and attributes to provide a userdefined comparison (masking variable file Contents), but so far this seems not possible.

Do I really have to Keep my reference files outside TC?



Regards,



Manfred

  • Hi Manfred, you are correct in that there is only a check() method available for a referenced file.

     


    In order to acheive what you require, you will need to utilise methods of the Files and aqFile objects as shown:


     


    function accessFiles() {


      // We have a referenced file in Files cjr_ini.


      // Test Complete only gives us Files.cjr_ini.Check();


      // Use methods on Files and aqFile to get the information wanted, e.g.


      // Get file path


      var filePath = Files.FileNameByName( "cjr_ini" );


      // Get file content


      var fileContent = aqFile.ReadWholeTextFile( filePath, aqFile.ctANSI ); 


      // Get file attributes


      var fileAttributes = aqFile.GetFileAttributes( filePath );


      


      Log.Message( filePath );


      Log.Message( fileContent );


      Log.Message( fileAttributes );


    }


     


    Regards,


    Phil Baird

3 Replies

  • Philip_Baird's avatar
    Philip_Baird
    Community Expert
    Hi Manfred, you are correct in that there is only a check() method available for a referenced file.

     


    In order to acheive what you require, you will need to utilise methods of the Files and aqFile objects as shown:


     


    function accessFiles() {


      // We have a referenced file in Files cjr_ini.


      // Test Complete only gives us Files.cjr_ini.Check();


      // Use methods on Files and aqFile to get the information wanted, e.g.


      // Get file path


      var filePath = Files.FileNameByName( "cjr_ini" );


      // Get file content


      var fileContent = aqFile.ReadWholeTextFile( filePath, aqFile.ctANSI ); 


      // Get file attributes


      var fileAttributes = aqFile.GetFileAttributes( filePath );


      


      Log.Message( filePath );


      Log.Message( fileContent );


      Log.Message( fileAttributes );


    }


     


    Regards,


    Phil Baird

  • Manfred_F's avatar
    Manfred_F
    Regular Contributor
    Thank You very much,

    this will do the Job..



    Regards

    Manfred