O GoConqr está de visual novo! Conte para nós o que você achou.

Módulo 18 de 22 · Mídia

Append to a file

Kostas Diakogiannis

Append to a file

Append to a file 

Massive success again! But wait a minute, if you observed really closely, you may have figured out, that the second time the contents of the file overwrote what the file already had from the first time. That means any time we write to a file, we first delete it's contents and we write on a white canvas from the beginning.

But what if i don't want to delete the content the file currently has? What if i just want to add content to the already existing one?

Then instead of the fs.writeFile (or fs.writeFileSync and it's equivalent functions) we use the fs.appendFile (fs.appendFileSync etc) and wrap it into a promise.

This will append the content to the content of the existing file, or it will even create a file from scratch if this file does not exist! Pretty cool uh?

 

Instruções

Para avançar no curso, envie uma tentativa deste quiz. Você pode enviá-la depois da última pergunta.

Ir para o módulo escolhido

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?