B4R Question Clear ESP8266 files on flash

Discussion in 'B4R Questions' started by bdunkleysmith, Apr 30, 2018.

  1. bdunkleysmith

    bdunkleysmith Member Licensed User

    I am working on an application in which I save SSID passwords to individual files on the ESP8266 using rESP8266FileSystem.

    During development I appear to have accidentally created a file with a null file name which is 8 bytes long, in addition to another valid file as indicated by the result when I run

    Code:
    Sub ListFiles
        
    Log("Listing password files:")
        
    For Each f As File In fs.ListFiles("")
            
    Log("Name: ", f.Name, ", Size: ", f.Size)
        
    Next
    End Sub
    Listing password files:
    Name: , Size: 8
    Name: Telstra1943, Size: 8

    Having a null file name apparently means this code

    Code:
    For Each f As File In fs.ListFiles("")
        fs.Remove(f.Name)
    Next
    fails or at least doesn't delete the file.

    Any suggestions as to how I can clear the files from the flash - it doesn't matter if I have to delete any valid files in the process because I can recreate those once the filesystem is purged.

    Thanks in anticipation of suggestions.
     
  2. tigrot

    tigrot Well-Known Member Licensed User

    Once I created on a windows 10 folder a file with 0 size. I've been trying to delete it for years, with no success. I've tryed to use some utilty as well. Same result. Seems I've to format drive again to get rid of it. I'll do when I'll grow up!
    I think that formating will solve: http://esp8266.github.io/Arduino/versions/2.0.0/doc/filesystem.html for your reference
     
  3. bdunkleysmith

    bdunkleysmith Member Licensed User

    Thanks Tigrot. I overlooked the Format function of the rESP8266FileSystem library and following your suggestion I have now successfully used that to solve my problem.
     
    tigrot likes this.
  4. Johan Hormaza

    Johan Hormaza Active Member Licensed User

    And to create and fill a file ".txt"
     
  5. tigrot

    tigrot Well-Known Member Licensed User

    Use this library to write on flash, open file, write and close as usual. I personally use a sd card.
     
  6. Johan Hormaza

    Johan Hormaza Active Member Licensed User

    But how could I create a file. Thank you!
     
  7. tigrot

    tigrot Well-Known Member Licensed User

  8. tigrot

    tigrot Well-Known Member Licensed User

    Johan Hormaza likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice