Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 4 - Secure File Deletion in Delphi
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Secure File Deletion in Delphi
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 11
    2005-11-14

    Table of Contents:
  • Secure File Deletion in Delphi
  • Building the GUI
  • The code
  • The rest of the code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Secure File Deletion in Delphi - The rest of the code


    (Page 4 of 4 )

    Click on the "Delete Files" button and add the following code:

    procedure TForm1.SpeedButton1Click(Sender:
    TObject);
    var
    files:integer;
    begin
    //if no files are selected then show a warning
    if listbox1.Items.Count < 1 then
    begin
    MessageDlg('There are no files selected to
    delete. Please try again.', mtWarning,[mbOk],
    0);
    exit;
    end
    else  begin
    if MessageDlg('You will not be able to recover
    the files once shredded.'+#13#10+' Do you want
    to continue?', mtInformation,
          [mbYes, mbNo], 0)=mrYes then
    for files:=0 to listbox1.Items.Count-1 do
    begin
    //retrieve dragged files one by one, overwrite
    and delete
    getridofFile(listbox1.Items[files]);
    end;
    //update the listbox
     filelistbox1.Update;
    //reset progressbar,labels and form
     prog.Position:=0;
     label1.Caption:='0';
     form1.listbox1.Clear;
     label1.Caption:='0';
    //Display  a message
     MessageDlg('File(s) deleted', mtInformation,
          [mbOk], 0);
     end;
    end;

    This is the most important bit of code. It actually executes the two procedures outlined earlier. Let's go through it. First, it checks whether the files have been selected, and displays the appropriate messages. If files have been selected, then it calls the "getridofFile" procedure, and displays a message depending on whether the operation was successful.

    Next, click on the listbox, then go to the object inspector’s events tab and double click on the "dragdrop" field and enter the following code:

    procedure TForm1.ListBox1DragDrop(Sender,
    Source: TObject; X, Y: Integer);
    var i,c: integer;
    begin

    with FileListBox1 do
     if SelCount > 0 then
      for i:=0 to Items.Count-1 do
       if Selected[i] then
         ListBox1.Items.Add(items[i]);
     c:=ListBox1.Items.count;
    label1.Caption:=inttostr(c);

    end;

    Select the listbox and do the same, except double click on dragover field and enter the code below:

    procedure TForm1.ListBox1DragOver(Sender,
    Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    begin
    //where are the files coming from?
     if source is TFilelistbox then
    accept:=true;
    end;

    The above code will handle the drag and drop actions, which are central to the app. Basically, the user will be able to select more than one file at a time and drag and drop them into the listbox.

    The last bit of code will deal with setting the directory list box to a default drive and setting the progressbar to 100.

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    //set progressbar max
     prog.Max:=100;
    //set directory default
    directorylistbox1.Directory:='c:\';
    end;

    This will enable you to select all files at once…

    procedure TForm1.SpeedButton2Click(Sender:
    TObject);
    begin
    filelistbox1.SelectAll;
    {MessageDlg('Right Click and drag selected
    files', mtInformation,
          [mbOk], 0);}
    MessageDlg ('Click and hold down left mouse
    button and drag selected files',    mtCustom, [mbOK], 0);
    end;

    That’s it. Start deleting!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · A good introduction to an increasingly important subject.The author mentions the...
       · The repeated rewriting of code here will simply erase the cache multiple times...
       · Presumably renaming the file is so it's name entry is overwritten in the directory,...
       · Hi, Please be aware that main code that does the DOD wiping is grossly...
       · The code does write over the original clusters. If you check the lcn,vcn and...
     

    DELPHI-KYLIX ARTICLES

    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT