B4R Question Clear ESP8266 files on flash

bdunkleysmith

Active Member
Licensed User
Longtime 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

B4X:
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

B4X:
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.
 

bdunkleysmith

Active Member
Licensed User
Longtime 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.
 
Upvote 0
Top