echo '' ;

ESP8266 NodeMCU Module – File

 


File Modes

  •    – read mode (the default)
  • w   – write mode
  • a    – append mode
  • r+  – update mode, all previous data is preserved
  • w+– update mode, all previous data is erased
  • a+ – append update mode, previous data is preserved, writing is only allowed at the end of file

File Functions

  • file.open()  – Open a file (Create a new file when write mode)
    • file.open(filename, mode)
      • Eg : file.open(“New_File”, “r”)
      • returns nil if file not open, else file opened returns true
  • file.remove() – Remove a file.
    • file.remove(filename)
      • Eg: file.remove(“New_File”)
      • return nil (nothing)
  • file.rename() – Rename the file.
    • file.rename(oldname, newname)
      • Eg: file.rename(“Old_File”, “New_File”)
      • return true if success, false if error.

Create a New file

  • file.open(“File_Name”, “Mode”) 

File – Hello world Program

file.open("hello/world.txt", "w")
file.writeline("Hello World!")                                                
file.close()

 


Next :

Previous :


 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from ArunEworld

Subscribe now to keep reading and get access to the full archive.

Continue reading