Forum Discussion
Philip_Baird
12 years agoCommunity Expert
Hi Ted, two things:
1. The line testFile = aqString.Replace(testDataFile, "\\", "\\\\", false); is not required. Using the "\" escape character is only required when defining literal strings for compile time evaluation, e.g.
var path = "C:\\TestFolder\\TestData\\TestFile.xlsx";
If you pass "path" to a function, then escaping the "\" character is not required.
2. You can use the aqFile::Exists() method to determine file availability instead of having to create an instance of aqFileInfo for this purpose.
The following may be of use as an example:
function setTestDataDriver(testDataFile) {
var testFile;
try {
if(aqFile.Exists(testDataFile) ) {
Project.Variables.rptTestFile = DDT.ExcelDriver(testDataFile , "Reports", true);
}
} catch(e) {
Log.Error(e.description);
}
}
Regards,
Phil Baird