Forum Discussion

murugans1011's avatar
murugans1011
Regular Contributor
12 years ago

Getting filepath

Hi,



Is there any that i get path of the file something lik this



  filepath=  "E:\MyProject\test1.exe"



does Tc has any builtin function for this or any workaround with



Filesystemobject?

5 Replies

  • jorgesimoes1983's avatar
    jorgesimoes1983
    Regular Contributor
    I wrote this function to get the latest created folder in a group of folder.



    You pass the root folder as argument.



    Maybe you can work from here to suit the function to your needs.



    /**

    * Get last created folder <br>

    * Log folder of Description.tcLog<br>

    * @method ShowFolderList

    * Param folderspec {string} root folder

    */

    function ShowFolderList(folderspec)

    {

       var fso, f, fc, s;

       var pasta_mais_recente;

       var data_mais_recente='';

       fso = new ActiveXObject("Scripting.FileSystemObject");

       f = fso.GetFolder(folderspec);   

       fc = new Enumerator(f.SubFolders);

       s = "";

       for (; !fc.atEnd(); fc.moveNext())

       {

          // first iteration is the most recent folder

          if(data_mais_recente==''){

            data_mais_recente = fc.item().DateCreated;

            s = fc.item();

          }

          

          // if folder is newer, updates

          if(fc.item().DateCreated > data_mais_recente)

          {

            data_mais_recente = fc.item().DateCreated;

            //s = fc.item().Name;

            s = fc.item();

          }

            

          Log.Message(fc.item().DateCreated);

          //s += fc.item();

          //s += "<br>";

       }

       

       Log.Message(data_mais_recente);

       Log.Message("Latest folder "+ s, s);

       s+="\\";

       return(s);

    }
  • murugans1011's avatar
    murugans1011
    Regular Contributor
    Hi i was working with general files. the sample given aqFileSystem only searches file in main folder. i couldnt able to serach files in subfolder





    Sub FileFinder





      Set foundFiles = aqFileSystem.FindFiles("C:\Work\", "*.exe") 





      If Not foundFiles Is Nothing Then

         While foundFiles.HasNext

           Set aFile = foundFiles.Next

           Log.Message aFile.Name

         Wend

      Else

          Log.Message "No files were found."

      End If

    End Sub





    Th code Searches file in main folder named 'work'. now  i need to search for a file in subfolders also if the file is not found in main folder is that possible?