I'm using a text file to keep a number that is used in controlled documents.
For example file contents can be: 17-154. So when we need to create a new controlled document it will be 17-155 and so forth.
All that works fine, but:
- What if the text file does not exist?
I would like to create a text file from scratch and write '17-001' to it...
var oFile = new File( sFileName );
oFile.encoding = "UTF-8";
alert( "Cannot create file: " + sFileName );
oFile.writeln( "Whatever you want to write to the file" );
If you want to append text to an existing file, use oFile.open('a') instead. Don't forget to close the file after writing to it.