Forum Discussion

NisHera's avatar
NisHera
Valued Contributor
10 years ago
Solved

Copy file in unknown sub directory

How can i copy file in known directory un- known sub directory



eg my application generate xml file.

It is placed in spool directory and sub derectory with random name 

like C:\Spool\782832jdnsh6a938jfnc37\12334567.XML



aqFile.Copy( Project.Variables.FilePath+"\*\\\\"+"*.XML","C:\\ myfolder\\New.XML",true); doesnot work.
  • You can use aqFileSystem.FindFiles to find the file by its partial path, and then copy the found file.



    //JScript

    var foundFiles = aqFileSystem.FindFiles("C:\\Spool", "*.xml", true /* search subfolders */);

    if (foundFiles != null)

    {

      foundFiles(0).Copy("C:\\myfolder\\New.XML", true);

    }

    else

    {

      Log.Error("File not found");

    }

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    You can use aqFileSystem.FindFiles to find the file by its partial path, and then copy the found file.



    //JScript

    var foundFiles = aqFileSystem.FindFiles("C:\\Spool", "*.xml", true /* search subfolders */);

    if (foundFiles != null)

    {

      foundFiles(0).Copy("C:\\myfolder\\New.XML", true);

    }

    else

    {

      Log.Error("File not found");

    }

  • Hi there,



    Have you conciderred this?



    Altus



    [Posted too late - should have refreshed :)]