1. Is there equivalent to java's File.deleteOnExit() in .NET BCL? stackoverflow.comProbably I could make an application domain and hook to DomainUnload event, but I'd like to do that on primary app domain. |
2. File Shredding & deleteOnExit() coderanch.comprivate void wipe(File file) { try { FileChannel rwChannel = new RandomAccessFile(file, "rw").getChannel(); int numBytes = (int)rwChannel.size(); ByteBuffer buffer = rwChannel.map(FileChannel.MapMode.READ_WRITE, 0, numBytes); buffer.clear(); byte[] randomBytes = new byte[numBytes]; new Random().nextBytes(randomBytes); buffer.put(randomBytes); rwChannel.write(buffer); rwChannel.close(); } catch(Exception e) { JOptionPane.showMessageDialog(new JFrame(), e.getMessage(), "", 2); } } This above method attempts to wipe a given file. The files I want wiped are created ... |
3. File.deleteOnExit Bug? forums.oracle.com |
4. Status of BUG: File.deleteOnExit() does not work on open files (win32) ? forums.oracle.comNo. You will have to add a Runtime shutdownHoook and code it yourself. But this sort of thing worries me - deleting entire directory structures at any time, and especially at JVM exit time. Do you really need to do this? and why? what is the significance of the file that is still there preventing deletion of the directory? and why ... |