Forum Discussion
Dmitry_Nikolaev
13 years agoStaff
Hi Jake,
It looks like you have faced a known problem with aqTextFile.WriteLine. It will be fixed in one of future TestComplete updates.
As an alternative, you can try using the WriteLine method of the TextStream object.
Also, one of TestComplete users suggested the following approach:
function doSaveFile(strAbsoluteFilePath, strCharSet, strFileContents, blnOverwrite) {
try {
if (!strAbsoluteFilePath) {
throw new Error(1, "Required parameter \"strAbsoluteFilePath\" was not defined");
}
if (!strCharSet) {
throw new Error(2, "Required parameter \"strCharSet\" was not defined");
}
if (typeof strFileContents != "string") {
throw new Error(3, "Required parameter \"strFileContents\" was not a string");
}
var objStream = new ActiveXObject("ADODB.Stream");
objStream.Open();
try {
objStream.CharSet = strCharSet;
objStream.WriteText(strFileContents);
//objStream.SaveToFile(strAbsoluteFilePath, (blnOverwrite ? adSaveCreateOverWrite : adSaveCreateNotExist));
objStream.SaveToFile(strAbsoluteFilePath, 1);
return true;
}
catch (err) {
throw new Error(err.number, "SaveToFile failed:\r\n" + err.description);
}
finally {
objStream.Close(); // Always close the stream regardless of what happens
}
return false;
}
catch (err) {
throw new Error(err.number, "Function doSaveFile() failed with parameters strAbsoluteFilePath=\"" + strAbsoluteFilePath + "\", strCharSet=\"" + strCharSet + "\", strFileContents=\"" + strFileContents + "\", blnOverwrite=\"" + blnOverwrite + "\". Message=\r\n" + err.description);
}
}
Related Content
- 12 months agoRavikaanth
- 10 years agoTonyM
- 9 months agoEgg
Recent Discussions
- 3 days agoMW_Didata