Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileCopy and/or fso.CopyFile, then Kill it

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,486
5
38
US
If I use:
[tt]
FileSystemObject.CopyFile "c:\mydocuments\letter.doc", "c:\tempfolder\"
[/tt]or [tt]
FileCopy "c:\mydocuments\letter.doc" , "c:\tempfolder\letter.doc"
[/tt]
What do I need to do before I can:
[tt]
Kill "c:\mydocuments\letter.doc"[/tt]

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.
 
>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.
 
>BTW, I don't want to Move the file

Can you explain why not? FileCopy followed by kill is exactly the same as Move
 
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. :-(

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.
 
Well, this is a case where you try to help someone without knowing the whole picture. :-(
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top