Title: Message

Why not use the filestream copy, and then set the date/time of the copied file to suit?

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Bird
Sent: Friday, 22 September 2006 10:35 a.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: RE: [DUG] Copying files problem

 

Still foxed by this problem!

 

The main reason I wanted to use an API method (ie copying a file rather than using FileStream etc to copy the data) is I want to preserve the date and time filestamps on the files, as I do a smart copy - only copying files that have a later modification date.

 

On further testing, definitely on one site the copyfile function fails every time.  I also tried a dos batchfile and shellexecute with the current directory set to the destination folder, which also consistently failed, even if the destination file was deleted first (that is attempted to delete in the batch file).

 

*HOWEVER* Windows explorer copy and paste for the main part always worked - to my mind this shows folder permissions etc were not to blame.

I did notice that once Explorer came up with an unusual message like "This copy operation cannot preserve the encryption on the file" which sounds like either the server or pc HD are encrypted.  And the real time antivirus is etrust which I have had unusual problems with in the past (such as ignoring exceptions to real time scanning).

 

Does anyone know the API call that explorer uses - or an alternative to copyfile or any other suggestions?

 

I think I also need to investigate the exit status of the copyfile command....

 

 

(FYI The routines I use are below - the 10 second allowance is because copying from eg NTFS to FAT32 will slightly alter the files modfication time because of the difference in time resolution of the file stamps)

 

function xfFilesChanged(file1:string;file2:string):integer;
//check 2 files modification date
//returns 0=both files same, 1=file1 later, 2=file2 later
//note if one file does not exist, returns other as later
var
fileage1,fileage2:integer;
dtdate1,dtdate2,dt10secs:TDateTime;
begin
   result:=0;
   fileage1:=FileAge(file1);
   fileage2:=FileAge(file2);
   if (fileage1<0) and (fileage2>0)then
   begin
      result:=2;
      exit;
   end;
   if (fileage2<0) and (fileage1>0)then
   begin
      result:=1;
      exit;
   end;
   if (fileage1<0) or (fileage2<0) then exit;  //maybe both don't exist
   dtdate1:=FileDatetoDateTime(fileage1);
   dtdate2:=FileDatetoDateTime(fileage2);
   if dtdate1=dtdate2 then
   begin
      result:=0;
      exit;
   end;
   //now if not same, check if within 10 secs
   //in case of different filesystems
   dt10secs:=encodetime(0,0,10,0);
   if (dtdate2>(dtdate1-dt10secs))
     and (dtdate2<(dtdate1+dt10secs)) then
   begin
     result:=0;
     exit;
   end;
   //still different
   if dtdate1>dtdate2 then result:=1
   else result:=2;
end;

 

function xfCopyFileifLater(File1:string;File2:string):integer;
//returns 0=no copy needed (files same) 1=File1 copied 2=file2 is later so not copied
var
WhichisLater:integer;
begin
  WhichisLater:=xfFilesChanged(file1,file2);
  if WhichisLater=1 then copyfile(Pchar(File1),Pchar(File2),false);
  result:=Whichislater;
end;

 

 

John

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Phil Middlemiss
Sent: Thursday, 21 September 2006 9:44 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Copying files problem

What about trying a different method such as the example in the help for TFileStream? Basically just reading a bit from one stream and writing it to the other until it's all done. We use this method a lot and it seems very reliable.

Phil.

John Bird wrote:

Well that might explain something, as the current directory when this particular copy is done is the source file directory, which is usually on a different drive from the destination directory.

 

I will experiment with altering this.

 

 

John

-----Original Message-----
From: Rohit Gupta [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 21 September 2006 8:11 a.m.
To: [EMAIL PROTECTED]; NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Copying files problem

We get this sometimes.  Its as if the app has different access rights to the user, even on Win2K.  We had an incident (still unresolved) a few days ago.... Maybe its new windows updates.  One thing to note is that since Win95 (at least), windows does the following :-

To Copy file from DirA to DirB

1.  Make DirB the current directory
2.  Copy from DirA
3.  Change back to original Current Directory

Sometimes, step 1 fails but there are no errors and it copies the file into the current directory instead.  And I cant figure out any way to detect this !!


John Bird wrote:

I copy program files using a line like:

 

copyfile(Pchar(File1),Pchar(File2),false);

 

Sometimes this fails for no obvious reason (File2 is not in use for instance), and if I open Windows explorer and copy from there it usually works, if not if I delete the destination file and then paste works fine.  To my mind this proves it is not a problem with permissions to write into this folder...

 

File1 is on the server, File2 is local on C drive.

 

any ideas?

 

Background:

This is a neat way of updating programs - updated exe files are loaded into a central update folder (which is not used except for copying from), and the startup program copies any updated programs into the local C drive working folder before any programs are in use.   Works wonderfully except on one site......I wonder the problem is from not being administrator or something in the PC setup being locked down....(although I don't know why as Windows Explorer works)

 

 

John Bird

email

 [EMAIL PROTECTED]

 [EMAIL PROTECTED]

Expert in Beyond Software

Ph land (03)384-4527  mobile (027)484-4528

92 Soleares Ave, Mt Pleasant

Christchurch

Web www.jbcl.co.nz

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Gary T. Benner
Sent: Wednesday, 20 September 2006 5:17 p.m.
To: [EMAIL PROTECTED]
Cc: [email protected]
Subject: RE: [DUG] Integrating Indy HTTPServer

[Reply]

HI Jeremy,

If you are incorporating this into an app, may I suggest you dynamically instantiate the component each time you make an http call. I found this made for greater reliability.

kr

Gary

At 13:53 on 20/09/2006 you wrote

>To : [email protected]

>CC :

>From: Jeremy Coulter, [EMAIL PROTECTED]

>Content Type: text/html

>Attached:

>

>This is a multi-part message in MIME format.

>

>

>

>

>Hi all.

>List seems to have been VERY quite over the last few days.

>

>Has anyone successfully integrated the Indy HTTP Server into an app.?

>I am going to be adding an HTTP Server into an app. I have and wondered if

>anyone had used the indy one, and how they found it?

>Can I use ISAPI or CGI apps. with it does anyone know?

>

>

>Thanks, Jeremy

>

>--

>No virus found in this outgoing message.

>Checked by AVG Free Edition.

>Version: 7.1.405 / Virus Database: 268.12.5/451 - Release Date: 19/09/2006

>

>

>

>_______________________________________________

>Delphi mailing list

>[email protected]

>http://ns3.123.co.nz/mailman/listinfo/delphi



Ref#: 41006



__________ NOD32 1.1461 (20060329) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



 
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi
  

 

--

Rohit Gupta

B.E. Elec.   M.E.   Mem IEEE    Associate IEE

Technical Manager

Computer Fanatics Limited

 

Tel     +64 9 4892280

Fax    +64 9 4892290

Email  [EMAIL PROTECTED]

Web    www.cfl.co.nz

 


This email and any attachments contain information, which is confidential and may be subject to legal privilege and copyright. If you are not the intended recipient, you must not use, distribute or copy this email or attachments. If you have received this in error, please notify us immediately by return email and then delete this email and any attachments.



__________ NOD32 1.1461 (20060329) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com




 
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi
  



 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.6/453 - Release Date: 9/20/2006
  



__________ NOD32 1.1461 (20060329) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to