Link to home
Start Free TrialLog in
Avatar of bhummel
bhummel

asked on

Moving Files in VB 5.0

Greetings,
A process I have uses files that reside on another server. My problem is that server more that occasionally crashes. What is the best way to move the files I need to another server using VB if possible? FileCopy will only copy info into another file.

Also, how can I access the modified date of the file. I only want to move files that were created/modified yesterday.

Would a .bat file be easier? This should be fairly easy, I just can seem to find any documentation.

Thanks,
Brad
ASKER CERTIFIED SOLUTION
Avatar of clifABB
clifABB

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MikeABB
MikeABB

You can move the files to the other machine using the name function.

Name <oldfilename> as <newfilename>

as for checking the modified date, you could use the GetFileTime API:

Declare Function GetFileTime& Lib "kernel32" (ByVal hFile as Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime as FILETIME)

Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type

lpLastWriteTime will give you your last modification time.

You can get more information on this function in the MSDN Online documentation.  After you get the time of the file, you can use the DateDiff function to determine if the file needs to be copied.
bhummel,
    Sorry about that, It was just pointed out to me, by clifABB, that the Name statement only works when files are on the same directory.  You should probably use the FileDateTime function too.  I was unaware that it existed.  Sorry again!

MikeABB
Not the same directory, but both source and destination must be on the same drive.