README.md

December 4, 2022 ยท View on GitHub

*** Destroy a file without getting error! ***

Description

This DOES use the kill function, but when you use this it actually opens the file you want to destroy, cleans it out, then deletes it so you don't get any error because of sensitive data!

More Info

File To Delete

Make sure not to delete win.com, win.ini, config.sys, himem.sys, autoexec.bat or any of those files, lol ;D

No more file

Submitted On
ByMatt Evans
LevelUnknown
User Rating4.0 (36 globes from 9 users)
CompatibilityVB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
CategoryFiles/ File Controls/ Input/ Output
WorldVisual Basic
Archive File

Source Code

Sub DestroyFile(sFileName As String)
  Dim Block1 As String, Block2 As String, Blocks As Long
  Dim hFileHandle As Integer, iLoop As Long, offset As Long
  'Create two buffers with a specified 'wipe-out' characters
  Const BLOCKSIZE = 4096
  Block1 = String(BLOCKSIZE, "X")
  Block2 = String(BLOCKSIZE, " ")
  'Overwrite the file contents with the wipe-out characters
  hFileHandle = FreeFile
  Open sFileName For Binary As hFileHandle
    Blocks = (LOF(hFileHandle) \ BLOCKSIZE) + 1
    For iLoop = 1 To Blocks
      offset = Seek(hFileHandle)
      Put hFileHandle, , Block1
      Put hFileHandle, offset, Block2
    Next iLoop
  Close hFileHandle
  'Now you can delete the file, which contains no sensitive data
  Kill sFileName
End Sub