File Delete hangs the application

I suspect my SD card file system has become corrupt. That is not the biggest problem here… the biggest issue is that if my application calls:


…then the application hangs. Not only does it hang but my debugger loses connection. And this is happening early enough in the boot process of my application that it prevents VS2015 from connecting to the target to download new code! I have to pull out MFDeploy to load a “hello world” application just to be able to re-attach the debugger to load new applications to test.

What makes this interesting is that if I call File.Exists(“filename”) or open a stream and read from the file then it all works great.

Does anyone have any ideas how I can write my code so it doesn’t lock up when trying to delete a file? Are there any functions I can call before to prevent this from happening? Is there any way to recover from this error without formatting the SD card?

One more point to make… I’ve done multiple google searches and it seems like others have posted to other forums about this problem going back a few years but no one has ever posted a solution. I hope that isn’t because there isn’t a solution…

Might be an idea to post this as an issue in the Netduino SDK GitHub repository.