User Tools

Site Tools




Method to read and write files. This method is a shorthand method for both the functions readFile() and writeFile(). This function is the equivalent of the method content().


To get the contents of a file:

var file = new File("C:/myfile.txt");
var filecontents = file_content(file);

To write a string to a file:

var content = "String to replace file content with";
var file = new File("C:/myfile.txt");
var contents = file_content(file, content);

Note: This function will replace all content in the file. Use the ExtendScript default file manipulation for more granular options.


When parameters are omitted, this method gets the content of the file.

Parameter Data type Required Description
file file object True The file to read content from or write content to
content string The string to write to the file
encoding string The encoding to write the file. When not specified the default encoding UTF-8 is used

Return Values

Value Meaning
null The file does not exist
string The contents of the file
true The specified contents was written to the file
file/file_content.txt · Last modified: 2017/05/25 10:16 (external edit)