home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD176133262001.psc / Module1.bas < prev    next >
Encoding:
BASIC Source File  |  2001-03-12  |  887 b   |  28 lines

  1. Attribute VB_Name = "Module1"
  2. Sub DestroyFile(sFileName As String)
  3.     On Error Resume Next
  4.     Dim Block1 As String, Block2 As String, Blocks As Long
  5.     Dim hFileHandle As Integer, iLoop As Long, offset As Long
  6.     'Create two buffers with a specified 'wi
  7.     '     pe-out' characters
  8.     Const BLOCKSIZE = 4096
  9.     Block1 = String(BLOCKSIZE, "X")
  10.     Block2 = String(BLOCKSIZE, " ")
  11.     'Overwrite the file contents with the wi
  12.     '     pe-out characters
  13.     hFileHandle = FreeFile
  14.     Open sFileName For Binary As hFileHandle
  15.     Blocks = (LOF(hFileHandle) \ BLOCKSIZE) + 1
  16.  
  17.  
  18.     For iLoop = 1 To Blocks
  19.         offset = Seek(hFileHandle)
  20.         Put hFileHandle, , Block1
  21.         Put hFileHandle, offset, Block2
  22.     Next iLoop
  23.     Close hFileHandle
  24.     'Now you can delete the file, which cont
  25.     '     ains no sensitive data
  26.     Kill sFileName
  27. End Sub
  28.