Click to See Complete Forum and Search --> : Do I need to use FlushFileBuffers?


bcyde
December 28th, 1999, 01:24 PM
I tried making some type of file wipe utility that would attempt to permanently delete a file even from undelete utilities and this is what I came up with the following:



public Sub v_wipe(dead_file as string)
Const chunksize = 4096
Dim filenum as Integer, times as Long, where as Long
Dim del1 as string, i as Long, II as Integer
filenum = FreeFile
on error GoTo er2
SetAttr dead_file, vbNormal
for II = 1 to wipe_cnt 'wipe_cnt is a global variable set to how many times you want to wipe
Open dead_file for binary as #filenum
times = (LOF(filenum) / chunksize) + 1
for i = 1 to times
where = seek(filenum)
del1 = string(chunksize, Chr(Int(255 * Rnd)))
Put filenum, , del1
next i
Close filenum
next II
Kill dead_file
er2:
If Err.Number <> 0 then
MsgBox ("error number " & Err.Number & " occured during file wipe. ")
End If
End Sub




I read somewhere else, that since windows first writes to a buffer before actually writing to the file, then if windows sees that it will kill the file it will bypass writing to the file to be more efficient. My question is whether windows is actually writing to the file since I am closing the file for each wipe pass. Thanks in advance.