whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

15 Visitors Online


 
...shred (delete w/o traces) files?
Autor: MiniKeks
Homepage: http://www.nss-bot.ch.vu
[ Print tip ]  

Tip Rating (20):  
     


procedure ShredderFile(FileName: string);
const
  
Buffer       = 1024;
  Counttowrite = 34;
  FillBuffer: array[0..5] of Integer = ($00, $FF, $00, $F0, $0F, $00);
var
  
arr: array[1..Buffer] of Byte;
  f: file;
  i, j, n: Integer;
begin
  
AssignFile(f, FileName);
  Reset(f, 1);
  n := FileSize(f);
  for j := 0 to Counttowrite do
  begin
    for 
i := 1 to div Buffer do
    begin
      
BlockWrite(f, FillBuffer[j], Buffer);
    end;
  end;
  CloseFile(f);
  RenameFile(FileName, ExtractFilepath(FileName) + '$000000.tmp');
  DeleteFile(ExtractFilepath(FileName) + '$000000.tmp');
end;

procedure ShredderAndDeleteFile(const FileName: string);
var
  
newname: string;
begin
  
// zuerst umbennen, dann später keine Rückschlüsse auf den Dateinamen möglich sind
  // first rename the file
  
newname := ExtractFilepath(FileName) + '$000000.tmp';

  if not RenameFile(FileName, newname) then
    raise
    
Exception.CreateFmt('Fehlercode 2: Kann %s nicht umbenennen!', [FileName]);

  ShredderFile(newname);

  DeleteFile(newname);
end;


// Aufruf / Call: ShredderAndDeleteFile(Edit1.Text)


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners