I'm downloading a file into a MemoryBlock and then creating a temp file and writing the block to it:
file = file.createTempFile("tmpFile"); FileOutputStream* os = file.createOutputStream(); if (os->write(mb.getData(), mb.getSize())) { os->flush(); }
I then copy this file to some other location, and try to delete it using file.delete();
It does not work. When trying to manually delete the file using the Windows Explorer, it says that my application is locking it.
How can I release the file/handle and just delete it?