[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

BeeJ

11/25/2011 5:05:00 AM

Using API CreateFile (Open), WriteBytes, CloseHandle etc to copy files.
But the copied file has the "Now" date and time and I want the original
source file date and time. I know how to change this but trying to
find so adjunct API to simply tell the copy process to maintain the
source date and time or some API to fixup before calling the
CloseHandle.
Is there some parameter or API call to signal this?


22 Answers

ralph

11/25/2011 5:56:00 AM

0

On Thu, 24 Nov 2011 21:04:49 -0800, BeeJ <nospam@spamnot.com> wrote:

>Using API CreateFile (Open), WriteBytes, CloseHandle etc to copy files.
>But the copied file has the "Now" date and time and I want the original
>source file date and time. I know how to change this but trying to
>find so adjunct API to simply tell the copy process to maintain the
>source date and time or some API to fixup before calling the
>CloseHandle.
>Is there some parameter or API call to signal this?
>

Don't copy. Move.

-ralph

ralph

11/25/2011 6:18:00 AM

0

On Thu, 24 Nov 2011 23:55:57 -0600, ralph <nt_consulting64@yahoo.net>
wrote:

>On Thu, 24 Nov 2011 21:04:49 -0800, BeeJ <nospam@spamnot.com> wrote:
>
>>Using API CreateFile (Open), WriteBytes, CloseHandle etc to copy files.
>>But the copied file has the "Now" date and time and I want the original
>>source file date and time. I know how to change this but trying to
>>find so adjunct API to simply tell the copy process to maintain the
>>source date and time or some API to fixup before calling the
>>CloseHandle.
>>Is there some parameter or API call to signal this?
>>
>
>Don't copy. Move.
>
>-ralph


Use Robocopy if you have it, or XCopy if you don't.
Otherwise it is going to be exactly as you already figured out:
Capture the original File info, copy the file, then touch the new file
with the original info, ie, how RoboCopy and XCopy do it.

-ralph

Thorsten Albers

11/25/2011 12:57:00 PM

0

BeeJ <nospam@spamnot.com> schrieb im Beitrag
<jan7lj$itb$1@dont-email.me>...
> Using API CreateFile (Open), WriteBytes, CloseHandle etc to copy files.
> But the copied file has the "Now" date and time and I want the original
> source file date and time. I know how to change this but trying to
> find so adjunct API to simply tell the copy process to maintain the
> source date and time or some API to fixup before calling the
> CloseHandle.
> Is there some parameter or API call to signal this?

Did you try GetFileTime() (source file) and SetFileTime() (destination
file, maybe immediately before CloseHandle() gets called)?

--
Thorsten Albers

gudea at gmx.de

MikeD

11/25/2011 1:21:00 PM

0



"BeeJ" <nospam@spamnot.com> wrote in message
news:jan7lj$itb$1@dont-email.me...
> Using API CreateFile (Open), WriteBytes, CloseHandle etc to copy files.
> But the copied file has the "Now" date and time and I want the original
> source file date and time. I know how to change this but trying to find
> so adjunct API to simply tell the copy process to maintain the source date
> and time or some API to fixup before calling the CloseHandle.
> Is there some parameter or API call to signal this?


You're creating a new file so of course its modified and create dates are
going to be the current date and time of when it's actually created. Why
aren't you just using VB's FileCopy statement, or if you really want to go
the API route, use SHFileOperation (or any of a number of other API
functions specifically intended for copying files such as CopyFile or
CopyFileEx). Why do you make things so hard on yourself?

Mike


Dee Earley

11/25/2011 2:17:00 PM

0

On 25/11/2011 13:20, MikeD wrote:
> "BeeJ" <nospam@spamnot.com> wrote in message
> news:jan7lj$itb$1@dont-email.me...
>> Using API CreateFile (Open), WriteBytes, CloseHandle etc to copy files.
>> But the copied file has the "Now" date and time and I want the
>> original source file date and time. I know how to change this but
>> trying to find so adjunct API to simply tell the copy process to
>> maintain the source date and time or some API to fixup before calling
>> the CloseHandle.
>> Is there some parameter or API call to signal this?
>
> You're creating a new file so of course its modified and create dates
> are going to be the current date and time of when it's actually created.
> Why aren't you just using VB's FileCopy statement, or if you really want
> to go the API route, use SHFileOperation (or any of a number of other
> API functions specifically intended for copying files such as CopyFile
> or CopyFileEx). Why do you make things so hard on yourself?

Just for reference, all these do is set the date and time afterwards for
you :)

--
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

BeeJ

11/25/2011 3:32:00 PM

0

1) copy files larger than 2G
2) control copy buffer size.
3) make sure flushbuffer is executed.
4) I like smaller gears. lol

As I said I know how to adjust the date after the copy.

I was just hoping that some API related to the low level stuff I am
using also adjusted the dates.

For example (not a really good example, but anyway). If I use Dir to
scan for files I only get the drive path filename. If I use
FindFirstFile I also get the size, attributes and all date info.
Using FindFirstFile speeds up my overall operation significantly.
Using Dir I then have to call APIs for filesize, attributes and dates.

Thanks for the feedback.


MikeD

11/25/2011 8:45:00 PM

0



"Deanna Earley" <dee.earley@icode.co.uk> wrote in message
news:jao81g$ihr$1@speranza.aioe.org...
> On 25/11/2011 13:20, MikeD wrote:
>> "BeeJ" <nospam@spamnot.com> wrote in message
>> news:jan7lj$itb$1@dont-email.me...
>>> Using API CreateFile (Open), WriteBytes, CloseHandle etc to copy files.
>>> But the copied file has the "Now" date and time and I want the
>>> original source file date and time. I know how to change this but
>>> trying to find so adjunct API to simply tell the copy process to
>>> maintain the source date and time or some API to fixup before calling
>>> the CloseHandle.
>>> Is there some parameter or API call to signal this?
>>
>> You're creating a new file so of course its modified and create dates
>> are going to be the current date and time of when it's actually created.
>> Why aren't you just using VB's FileCopy statement, or if you really want
>> to go the API route, use SHFileOperation (or any of a number of other
>> API functions specifically intended for copying files such as CopyFile
>> or CopyFileEx). Why do you make things so hard on yourself?
>
> Just for reference, all these do is set the date and time afterwards for
> you :)

I don't get what your point is. Sure, anytime you "copy" a file by whatever
means, you're first making a new file and then setting attributes to match
the original. And since there are several different statements/functions
that can do all of this for you with ONE call to whatever
statement/function, I don't get why BeeJ is doing things the hard way.
Unless he's doing more than merely copying files.

--
Mike



Heinrich Pfeifer

11/26/2011 11:22:00 AM

0

Am 25.11.2011 06:04, schrieb BeeJ:
> Using API CreateFile (Open), WriteBytes, CloseHandle etc to copy files.
> But the copied file has the "Now" date and time and I want the original
> source file date and time. I know how to change this but trying to find
> so adjunct API to simply tell the copy process to maintain the source
> date and time or some API to fixup before calling the CloseHandle.
> Is there some parameter or API call to signal this?

To copy a file without any modificatgion, use FileCopy


--

Heinrich
http://www....
mail: new<at>gartrip.de

Thorsten Albers

11/26/2011 1:35:00 PM

0

BeeJ <nospam@spamnot.com> schrieb im Beitrag
<jan7lj$itb$1@dont-email.me>...
> Using API CreateFile (Open), WriteBytes, CloseHandle etc to copy files.
> But the copied file has the "Now" date and time and I want the original
> source file date and time. I know how to change this but trying to
> find so adjunct API to simply tell the copy process to maintain the
> source date and time or some API to fixup before calling the
> CloseHandle.
> Is there some parameter or API call to signal this?

Did you try the 'hTemplateFile' parameter of CreateFile()?
According to the documentation the newly created file will have the same
attributes as the template file, but maybe it will have the same date too.
I didn't ever used this parameter. Maybe it's worth to give it a try...

--
Thorsten Albers

gudea at gmx.de

Jeff Johnson [MVP: VB]

11/28/2011 7:11:00 PM

0

"ralph" <nt_consulting64@yahoo.net> wrote in message
news:omcuc7526uastd731fhp3pe9ol52qnhduf@4ax.com...

> then touch the new file

Whoever came up with the term "touch" for this activity was a dirty old man.