System.IO.File.Create doesn't work with more than 245 files!?!?!

The code below crashes at exactly 245 files, I have four directories on the SD card but other than that the root is empty.


for (int i = 0; i < 256; i += 1)
{
	try
	{
	    string file = @ "\SD\" + i.ToString("D") + ".txt";
	    FileStream fs = System.IO.File.Create(file, 256);
	    fs.Flush();
	    fs.Close();
	    fs = null;
	}
	catch (Exception ex)
	{
	    Debug.Print("SA: " + ex.HResultToString());
	}
}

In the debug I see tons of these…

A first chance exception of type ‘System.IO.IOException’ occurred in Microsoft.SPOT.IO.dll
A first chance exception of type ‘System.IO.IOException’ occurred in System.IO.dll
SA: CLR_E_FILE_IO

I am an idiot. FAT vs FAT32. I reformatted the card and it’s working perfectly now.

Or put your folks in any folder but not in the root

I think his folks will be against it.

3 Likes

Funny :slight_smile:

Yes, my users/folks aren’t always smart enough to navigate beyond the root. They plug the SD card in and expect their files to magically appear onscreen. Having a folder called Data, etc. would confuse them. …Users :confused:

1 Like