MicroSD Format/delete

hi, im using an ethernet shield for an arduino uno. it really dont do a whole lot just sends a file over tcp port. the problem im having is if the power is turn off or get interrupted the file on the sdcard never gets removed and then the sketch will get stuck. is there a way to format the sdcard with the arduino during the setup part of the sketch? what the best way to go about this?

The Arduino cannot format a card. But you can delete a file. Usually you wouldn't - just start logging again with a new file name. If file0001.txt exists, then create file0002.txt