INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

FileCopy and/or fso.CopyFile, then Kill it

FileCopy and/or fso.CopyFile, then Kill it

(OP)
If I use:

FileSystemObject.CopyFile "c:\mydocuments\letter.doc", "c:\tempfolder\"
or
FileCopy "c:\mydocuments\letter.doc" , "c:\tempfolder\letter.doc"

What do I need to do before I can:

Kill "c:\mydocuments\letter.doc"


I need to wait until the file is done copying, right?
So if I have the FileCopy and just after that a Kill statement, I cannot Kill the file because it is copied.

BTW, I don't want to Move the file.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: FileCopy and/or fso.CopyFile, then Kill it

>I need to wait until the file is done copying, right?

I do not think so. FileCopy at least seems to work synchronously so the next line will not be executed until FileCopy is done.

This code;

CODE -->

Private Sub Command1_Click()

    FileCopy "the monty.jpg", "New folder\the monty.jpg"
    Kill "the monty.jpg"

End Sub
'and its reverse
Private Sub Command2_Click()

    FileCopy "New folder\the monty.jpg", "the monty.jpg"
    Kill "New folder\the monty.jpg"
    
End Sub 
..is working for me when the app/ current folder is a folder on the Desktop.

RE: FileCopy and/or fso.CopyFile, then Kill it

>BTW, I don't want to Move the file

Can you explain why not? FileCopy followed by kill is exactly the same as Move

RE: FileCopy and/or fso.CopyFile, then Kill it

(OP)
Sure strongm,

The big pictures is this:
There is a file in location A. (Actually) my co-worker was moving the file to location B, and then copy this file to another location (C). When stepping thru the code everything was OK, but when running the code while the move was taking place, the copy was causing an error. I assume the move was not done yet, so the copy could not take place. So I suggested to do the copy from A to B, copy from A to C, and Kill it in A.

I was trying to present it in the simplest way possible, but I guess I failed. sad

Thanks HughLerwill, I will have to look at this closer.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: FileCopy and/or fso.CopyFile, then Kill it

(OP)
Well, this is a case where you try to help someone without knowing the whole picture. sad
It turns out the VB 6 app starts a stored procedure in Oracle, app has to wait until the stored procedure (which creates the file on the server) is done running, application then have this file copied to 2 locations, and then deletes the file from original location.

It is done with some Wait implemented, so it is working (I’ve been told)

Thank you for your responses.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close