Skip to main content
Known Participant
July 24, 2019
Answered

Read/Write File in Extenstion

  • July 24, 2019
  • 2 replies
  • 912 views

Hi

How Can Create Or Read a File XML or etc whit JavaScript or etc in Extenstion?

And How Can Read XML File in Extension ?

This topic has been closed for replies.
Correct answer migueld83371718

You need to use the File object:

function readFile(path) {

  var file = new File(path);

  var fileOk = file.open("r");

  if (fileOk) {

    var content = file.read();

    file.close();

    return content

  }

}

function writeFile(path, content) {

  var file = new File(path);

  var fileOk = file.open("w");

  if(fileOk){

    file.write(content);

    file.close();

    return file;

  }

}

2 replies

Mahdi_UshAuthor
Known Participant
July 25, 2019

No Idea ??!

No Answer ?

nobody ?

migueld83371718
migueld83371718Correct answer
Inspiring
July 25, 2019

You need to use the File object:

function readFile(path) {

  var file = new File(path);

  var fileOk = file.open("r");

  if (fileOk) {

    var content = file.read();

    file.close();

    return content

  }

}

function writeFile(path, content) {

  var file = new File(path);

  var fileOk = file.open("w");

  if(fileOk){

    file.write(content);

    file.close();

    return file;

  }

}

Justin Taylor-Hyper Brew
Community Expert
Community Expert
July 25, 2019
OussK
Community Expert
Community Expert
July 24, 2019

Moved to AE scripting