Solved

Moving Files in VB 5.0

Posted on 1998-06-09
4
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 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