Unable to write to text file inside plugin folder

async function writeFile() {
   try {
      let myFolder = await require('uxp').storage.localFileSystem.getPluginFolder()
      let newFile = await myFolder.createFile("textFile.txt", { overwrite: true });
      console.log(newFile.mode)
      await newFile.write("It was a dark and stormy night."); 
   } catch (error) {
      console.log(error)
   }
}

console.log(newFile.mode) outputs

Symbol(readWrite)

yet I get the following error:

Error: The file uses a storage provider that is read-only.

Plugin folder, as stated in the docs, is read-only. I believe you should use data folder. At least I don’t have any issues when using getDataFolder()

1 Like

you’re right, I actually missed that. thank you!