Advertisement

11.28.2008 at 04:46AM PST, ID: 23941997 | Points: 500
[x]
Attachment Details

A faster way to save files to usb stick

Asked by chrislock in Delphi Programming Language, Algorithms, Kernel And Operating System Specific Programming

Delphi 7 XP embedded

Hi,

I am trying to save a file to two separate USB sticks. This file saving takes place frequently and is causing some difficulty. Sometimes the files are not saved and I suspect that the USB system is being overwhelmed. Unfortunately, this works fine on my machine, but the target machine (XP embedded using EWF) shows intermittent behaviour.
The files are saved withe date and time in the name and are also write protected after they are saved.
Is there a faster way? I dont really want to leave file systems open in case of power failure.


The routine is roughly as follows:


Procedure storetoUSB;
var s:string;
f:Tfilestream;
 begin // save data from last episode

s:='PN'+inttostr(database[216])+'_'; // add process number from database
s:=USBA+':'+s+'IMS'+formatdatetime('yymmdd_hhmm',now)+'.csv';


f:=tfilestream.create(s,fmcreate);
try
  IMSlist.savetostream(f);
  FlushFileBuffers(f.handle);
finally
  freeandnil(f);
end;


if filesetattr(s,SysUtils.faReadOnly)>0 then ; // set readonly

if (USBB<>#0) and (isdriveready(USBB)=true) then  // CVdatastick present
begin
s:='PN'+inttostr(database[216])+'_'; // add process number to IMS
s:=USBB+':'+s+'IMS'+formatdatetime('yymmdd_hhmm',now)+'.csv';

f:=tfilestream.create(s,fmcreate);
try
  IMSlist.savetostream(f);
  FlushFileBuffers(f.handle);

finally
  freeandnil(f);
end;

if filesetattr(s,SysUtils.faReadOnly)>0 then ; // set readonly

end;


end;
Start Free Trial
 
Loading Advertisement...
 
[+][-]11.29.2008 at 02:56AM PST, ID: 23059281

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.29.2008 at 04:10AM PST, ID: 23059386

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.29.2008 at 06:45AM PST, ID: 23059795

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628