I tried to create some
arduino ide and also write different data to these files.
my question(dout) is ,
how can i get a files that i am written int??
I tried to create some
arduino ide and also write different data to these files.
my question(dout) is ,
how can i get a files that i am written int??
Can you not just open a file and read from it ?
#include "FS.h"
int fileSize;
int bytesRead;
String fileName;
void setup()
{
Serial.begin(115200);
SPIFFS.begin();
Dir dir = SPIFFS.openDir("/");
while (dir.next())
{
fileName = dir.fileName();
Serial.print(dir.fileName());
File f = dir.openFile("r");
fileSize = (f.size());
Serial.print("\t\t");
Serial.println(fileSize);
readTheFile();
f.close();
}
}
void loop()
{
}
void readTheFile()
{
File f = SPIFFS.open(fileName, "r");
if (!f)
{
Serial.println("file open failed");
}
fileSize = (f.size());
Serial.println("====== Reading from SPIFFS file =======");
char buffer[10000]; //adjust this to just more than the largest file size expected
bytesRead = 0;
while (bytesRead < fileSize)
{
buffer[bytesRead] = f.read();
bytesRead++;
buffer[bytesRead] = '\0';
}
f.close();
Serial.println(buffer);
}