Board index » delphi » Where Should I delete a temporary directory for a networked paradox application

Where Should I delete a temporary directory for a networked paradox application

I am creating a temporary directory to locate Paradox.lck
and Pdoxusers.lck file. These files are deleted by BDE when my app
closes. My problem is that I would like to delete the directory after
these files are deleted by BDE?
        Where would I place this code? FIles seens to still exist when
I put the System.rmDir in the FormClose procedure.

TIA,

Sanjay

 

Re:Where Should I delete a temporary directory for a networked paradox application


Quote
Sanjay Sharma <s-sha...@flowbee.beckman.uiuc.edu> wrote:
>I am creating a temporary directory to locate Paradox.lck
>and Pdoxusers.lck file. These files are deleted by BDE when my app
>closes. My problem is that I would like to delete the directory after
>these files are deleted by BDE?
>    Where would I place this code? FIles seens to still exist when
>I put the System.rmDir in the FormClose procedure.

Hi Sanjay.

Here is the code which I use when required.

=======================
function TForm1.DeleteFilesInDir(aDirName:string):integer;
var
  T: TSHFileOpStruct;
begin
  try
    AppendStr(aDirName, #0#0);
    with T do
    begin
      Wnd := 0;  // no handle, therefore no animation
      wFunc := FO_DELETE;
      pFrom := pchar(aDirName);
      fFlags := FOF_SILENT or FOF_NOCONFIRMATION;
    end;
    Result := SHFileOperation(T);
  except
    Result := -1;
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Table1.Close;
  Session.Close;  // this removes default session lock files from
private directory
  if PrivMade then
  begin
    if DeleteFilesInDir(PrivDir) <> 0 then
      MessageDlg('Unable to delete temporary directory' + #13#10 +
PrivDir,mtWarning,[mbOK],0);
  end;
end;
====================
Regards,
Chris Roberts

Other Threads