Solved

Moving Files in VB 5.0

Posted on 1998-06-09
4
148 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

831 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