What is ActiveXObject and is it safe to use?
Using it to write an XML file (text file), and was wondering which of these 2 methods is best ?
Is there any Opus method of doing the same?
var stream = new ActiveXObject('ADODB.Stream');
stream.Type = 2; // Text
stream.Charset = 'utf-8';
stream.Open();
stream.WriteText(xmlArray);
stream.SaveToFile(workFolderPath + '\\Iconset.xml', 2); // Overwrite
stream.Close();
OR
var fso = new ActiveXObject('Scripting.FileSystemObject');
var textfile = fso.CreateTextFile(workFolderPath + '\\Iconset.xml', true, false);
textfile.WriteLine(xmlArray);
textfile.Close();
None, IMO. You can use the actual XML manager COM object (Msxml2.DOMDocument) to manipulate XMLs, so you don't have to worry about breaking the format, escaping illegal characters, etc.
But I think Opus uses a different XML parser, so that might not be necessary.
Many thanks, and for any future searches here is Opus method of doing same (note to self: book in some time to research this ActiveXObject and COM object)
var file = DOpus.FSUtil.OpenFile(workFolderPath + '\\Iconset.xml', 'wa');
if (file.error === 0)
{
file.Write(xmlArray);
file.Close();
}