Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why are Del##.MB and _QSQ## files created in Delphi6 Enterprize.? 2

Status
Not open for further replies.

terrytype

Programmer
Jun 1, 2011
97
ZA
My OS is MS-XP.Prof

Upon compiling my Projects I perpetually have these files created and accumulate in the Target Directory until I get "Memory exceeded" exception which needs to be deleted before I am able to continue.

Whilst creating a time-consuming nuisance to delete I have no idea of what use, if any,
these files are or can be put.

How can creation of these files be prevented?

Thanks in advance.


Old Man Delphi
 
These are temporary files created by the TQuery component.
You must configure the DBE to put these files in a sensible temporary location (like c:\temp).
At runtime you can set Session.PrivateDir for this purpose.
Or stop using the DBE all together, it is old and obsolote...

/Daddy

-----------------------------------------------------
Helping people is my job...
 
Thanks for that! [bigsmile] I note and respect your advice to stop using the DBE but I am relying upon it so extensively on Paradox tables not keen to fix things that aren't broke. Having said that I suspect I should walk away from the Paradox Tables which have a nasty habit of crashing the Index. I guess I should re-engineer my projects to be totally SQL reliant. Which raises other questions. Starting with HOW would I set about doing that without using the DBE. Another forum.[bigears]

Old Man Delphi
 
Please forgive me if this is an imposition.

Could you please be more specific with some code as to how and where I would put this in my application to be effective in Runtime?

Thanks in advance whosrdaddy



Old Man Delphi
 
You can configure the PrivateDir in the BDE setup or at runtime.

/Daddy

-----------------------------------------------------
Helping people is my job...
 
I refer to a previous response to this post which inter alia reads as follows ..

"The other approach is to assign a hard coded path to Session.PrivateDir.
Uses Windows, DBTables" .. which I undersstand

Whilst I remain most grateful for this advice which has earned the responder a well-deserved star I would be equally grateful if someone would be so kind as to please elaborate, for this
mere mortal, EXACTLY HOW AND WHERE an "const" and "appropriate place" might be to include this code in my Project.

"const
temp_path_len = 512;
var
temp_path: array[1 .. 512] of char;

//
// Place this code snippet at the
// approriate place in the code
//
GetTempPath(temp_path_len, @temp_path);
Session.PrivateDir := StrPas(@temp_path);

//
// or
//
// Session.PrivateDir := 'C:Temp';

Thanks in advance.


Old Man Delphi
 
It depends on the type of application really.
If it is just a forms application, I would do this init function in the OnCreate event of the main form.

/Daddy

-----------------------------------------------------
Helping people is my job...
 
Code:
Unit <myunitname>;

interface

uses ...

const
   temp_path_len = 512;

type
  TForm1 = class(TForm)
    ...
     procedure FormCreate(Sender: TObject);
  private
    function GetTempDirectory: String;
  public

  end;

var
  Form1: TForm1;

implementation

  ...

procedure TForm1.FormCreate(Sender: TObject);
var
  TempDirectory: String;
begin
  TempDirectory := GetTempDirectory;
  if DirectoryExists(TempDirectory) then
    Session.PrivateDir := TempDirectory
  else
    //Directory doesn't exist.
    //you can use ForceDirectories(TempDirectory) to create it.
    //but in Win7 and greater you may need elevated user access rights to do so.
end;

function TForm1.GetTempDirectory: String;
var
  temp_path: array[1..temp_path_len] of Char;
begin
  GetTempPath(temp_path_len, @temp_path);
  Result := StrPas(@temp_path);
end;

GetTempPath returns back the directory associated with the temp directory environment variable - no guarantee that the directory actually exists nor are you guaranteed to actually have write access to that directory. I didn't code to test write access, but you can easily add that if you feel the need to do so by writing and then deleting a file in the directory.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top