Hi, i am making a secure file deletion program. It works great, but it is extreamly slow. Any help will be appreciated. - Private Sub Command1_Click()
-
On Error Resume Next
-
q = ""
-
-
Dim file As String
-
CD.ShowOpen
-
If CD.FileName = "" Then End
-
file = CD.FileName
-
Open file For Binary As #1
-
tem = LOF(1)
-
-
Dim bytarray() As Byte
-
ReDim bytarray(1 To tem)
-
-
Get 1, 1, bytarray
-
q = ""
-
Form1.Hide
-
-
For b = 1 To Combo1.Text
-
For i = 1 To tem
-
mrand = Int(Rnd * (250))
-
bytarray(i) = Chr(mrand)
-
Next i
-
For g = 1 To tem
-
Put 1, g, bytarray(g)
-
Next g
-
Next b
-
-
Close #1
-
-
Kill file
-
-
MsgBox "Delete is complete", vbOKOnly, "Done!"
-
-
End
-
End Sub
-
4 1235
Is it possible to attach your program?
Q1 : what is q ?
Q2 : what is tem ? ...
Tem is the lof dictated in line 10 and for q, I forgot to remove it from the code.
Yours is working ????
This is the modification of Your code= - Option Explicit
-
-
Private Sub Command1_Click()
-
Dim BYTEARRAY() As Byte
-
Dim TEM As Long
-
Dim LOOPS As Integer
-
Dim BYTES As Long
-
Dim MRAND As Integer
-
'§ Select the file
-
On Error GoTo No_File
-
With CD
-
.CancelError = True
-
.ShowOpen
-
'§ Open the file
-
On Error Resume Next
-
Open .FileName For Binary As #1
-
'§ put file in array
-
TEM = LOF(1)
-
ReDim BYTEARRAY(1 To TEM)
-
Get 1, 1, BYTEARRAY
-
'§ Rewrite bytes
-
For LOOPS = 1 To Combo1.Text
-
For BYTES = 1 To TEM
-
MRAND = Int(Rnd * (250))
-
BYTEARRAY(BYTES) = MRAND
-
Put 1, BYTES, BYTEARRAY(BYTES)
-
Next
-
Label2 = LOOPS & " times rewritten"
-
Label2.Refresh
-
Next
-
Close #1
-
'§ Delete file
-
Kill .FileName
-
End With
-
MsgBox "Delete is complete", vbOKOnly, "Done!"
-
No_File:
-
End Sub
-
-
Private Sub Form_Load()
-
Dim COUNTER As Integer
-
'§ Fill list
-
For COUNTER = 0 To 90 Step 10
-
If COUNTER > 0 Then Combo1.AddItem COUNTER
-
Next
-
End Sub
-
But I have a lot of questions with Your approach:
Q1: why rewriting the bytes more than once ?
If You disable the line "Kill .Filename", you will see if You open the file (still present) all the bytes are changed.
So once is enough.
Q2: Why randomize the bytes ? if you enter only a character (like 100 for "d"), all the chars in the fill will be the same !( check with "Kill .Filename" off.
So here is the solution: - Option Explicit
-
-
Private Sub Command1_Click()
-
Dim BYTEARRAY() As Byte
-
Dim TEM As Long
-
Dim BYTESidx As Long
-
'§ Select the file
-
On Error GoTo No_File
-
With CD
-
.CancelError = True
-
.ShowOpen
-
'§ Open the file
-
On Error GoTo No_File
-
Open .FileName For Binary As #1
-
'§ put file in array
-
TEM = LOF(1)
-
ReDim BYTEARRAY(1 To TEM)
-
Get 1, 1, BYTEARRAY
-
'§ Rewrite bytes
-
For BYTESidx = 1 To TEM
-
BYTEARRAY(BYTESidx) = 100 '="d"
-
Next
-
Put 1, 1, BYTEARRAY
-
Close #1
-
'§ Delete file
-
Kill .FileName
-
End With
-
MsgBox "Delete is complete", vbOKOnly, "Done!"
-
Exit Sub
-
No_File:
-
MsgBox "No file selected"
-
End Sub
-
if they are overwritten once, than data can still be recovered. i am trying to have no data recovery.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike |
last post by:
I got the code below from an earlier post but I can't get it to work
(I get an error on the "for (i=0; i<a.length; i++)" line) Anyone have
code that works for cookies with keys?
> Anyone...
|
by: August Derleth |
last post by:
Cause I made such a hash of my first attempt, and in an effort to provide
PORTABLE code to solve the problem, I submit this solution to convert to
and from BCD values stored in longs. This should...
|
by: Hayato Iriumi |
last post by:
Hello,
I hear some hypes about creating code to generate C# or VB .NET code, that
is, code generation (sounds straight forward enough). I haven't really seen
how it's done in real world. I'm...
|
by: MLH |
last post by:
The largest integer A97 can deal with is 2,147,483,647,
as I understand it from HELP. I would be content to represent
larger integers as strings. For example, "2147483648" would
suit me fine. I...
|
by: HK |
last post by:
I'm wanting to get rid of a hardware load balancer and just use the Windows
2003 software load balancing with 2003 Server Web Edition.
I'm wondering if anyone here uploads ASP.NET code to 2 or...
|
by: Inny |
last post by:
Im not sure how to implement this script, it should pop the blank window only if someone clicks veiw source in the context menu or the toolbatr. help?
<html>
<head>
<SCRIPT>
<!--...
|
by: jacob navia |
last post by:
Hi
I am incorporating 128 Bit integer code into lcc-win and it would be
nice to have some code to test this feature.
Has anyone here code that uses 128 bit integers?
Thanks in advance
...
|
by: MrDeej |
last post by:
Hello guys.
I have a SQL table which uses ODBC from Access. I have a relatively large table with 850 000 rows. Today i tried to update a field in the table from NULL to a textvalue.
I clocked...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |