Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Public Class Overwriter
- Public Shared IsSelected As Integer
- Public Shared Function SecureDelete(ByVal flocation As String, ByVal passes As Integer) As Boolean
- Dim bw As BinaryWriter
- Try
- bw = New BinaryWriter(New FileStream(flocation, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
- Catch
- Return False
- End Try
- Dim fileSize As Long = bw.BaseStream.Length
- If fileSize <= 0 Then
- Return False
- End If
- Dim rnd = New Random()
- For i As Integer = 0 To passes - 1
- bw.Seek(0, SeekOrigin.Begin)
- For j As Long = 0 To fileSize - 1
- bw.Write(CChar(ChrW(rnd.[Next](0, 256))))
- Next
- bw.Flush()
- Next
- bw.Close()
- Try
- File.Delete(flocation)
- Catch
- Return False
- End Try
- Return True
- End Function
- Public Shared Function GetFileInfo(ByVal Path As String) As String
- Dim File As New FileInfo(Path)
- Dim Size As String = File.Length
- Dim Name As String = File.Name
- Dim LastEdit As String = File.LastAccessTime
- Return Size & Chr(123) & Name & Chr(123) & LastEdit
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment