Forum Discussion
3 Replies
- Dan_GawareckiOccasional Contributor
Hi Robert:
Thanks for the quick response!
"Try/Catch/Finally" login would be just fine - I just wasn't sure what was available (I did do a search on the forum and came up empty).
I'm doing
var propertyFile = aqFile.OpenTextFile(sPropFilePath, aqFile.faRead, aqFile.ctUTF8)
so I can read a few bits of information local to the workstation (e.g,. TechName, Machine Name, etc) so the tech don't have to keep typing it in for each test (they're coded to be very independent).
There's probably a better way to do this, but that's my ignorant approach at the moment.
- shankar_rCommunity Hero
Hi,
I had kind of same scenario, I use below code to do that.
function test() { CheckFile("C:\\Test\\Test.txt"); } function CheckFile(pathofthefile) { if(aqFile.Exists(pathofthefile)) //Or if(aqFileSystem.Exists(pathofthefile)) { Log.Checkpoint("File exists in the path " + pathofthefile); var txtFile = aqFile.OpenTextFile(pathofthefile,aqFile.faRead, aqFile.ctUnicode); try { if(txtFile.LinesCount > 0) { Log.Checkpoint("Text file contains " + txtFile.LinesCount + " lines"); return true; } else { Log.Warning("Text file is empty"); } } catch(e) { Log.Error("Unexpected error : " + e.stack); } } else { Log.Error(pathofthefile + " file not exists") }
return false; } - tristaanogreEsteemed Contributor
Actually, many of those values you're looking for are available right from the Sys object.
Perhaps you can skip, entirely, the process of reading the text file if the information you need can be obtained directly from ehre.