• Hi @user80339,
    The FileSystem library fs was updated to throw errors, so that these could be caught (It used to just output a warning when the docs were written)

    I have updated the docs, your code needs to look like this:

    try {
      fs.readdirSync();
     } catch (e) { //'Uncaught Error: Unable to mount media : NO_FILESYSTEM'
      console.log('Formatting FS - only need to do once');
      E.flashFatFS({ format: true });
    }
    fs.writeFileSync("hello.txt", "Hello World");
    console.log(fs.readFileSync("hello.txt")­); // prints "Hello World"
    fs.appendFileSync("hello.txt", "!!!");
    console.log(fs.readFileSync("hello.txt")­); // prints "Hello World!!!"
    

    If the filesystem is attempted to be read and can't, then the filesystem is created.

    Please note that this only needs to occur once. If the flash memory is erased, them you will need to format again.

    The try/catch above prevents E.flashFatFS({ format: true }); from erasing your files.

About

Avatar for Wilberforce @Wilberforce started