Solved

Moving Files in VB 5.0

Posted on 1998-06-09
4
150 Views
Last Modified: 2010-05-03
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
0
Comment
Question by:bhummel
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 100 total points
ID: 1462921
To move a file in vb, use a combination of Copy and Kill.  This is actually better because you can test for a complete (and accurate) copy before deleting the original file.

As far as access a file's date, use FileDateTime():
MyStamp = FileDateTime("TESTFILE")      
0
 

Expert Comment

by:MikeABB
ID: 1462922
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.
0
 

Expert Comment

by:MikeABB
ID: 1462923
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
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1462924
Not the same directory, but both source and destination must be on the same drive.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access 2013 combo box not working 3 51
vbModal 12 57
MS Access 03, TransferText, decimal places 8 78
Export Data to Different .csv Files 26 114
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question