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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying/Moving a file across drives 2

Status
Not open for further replies.

biot023

Programmer
Nov 8, 2001
403
GB
Hallo. I just discovered that 'rename' doesn't allow you to move a file across drives:
HELPFILE: "If a drive secifier is given in newname, the specifier must be the same as that given in oldname."
Does anyone know a way around this? Or a command that will let me copy then delete the file (which I would prefer)?
I guess I could open the file & copy it, but this is for moving AutoCad files, & I'd really rather not get into that if I could avoid it. The potential for disaster is incredible!

Any & all help gratefully received.

Cheers,
Douglas JL

If it don't make you laugh, it ain't true.
 
The file is renamed, not copied to a new file. So You have to copy the file from the old drive/location/name to the new drive/location/name and then delete the old file. Totte
 
Do you know any command that will just allow me to copy the file, rather than open it, read it, & paste it into a new file?

Douglas JL.

If it don't make you laugh, it ain't true.
 
Use the DOS Copy command. I do not know in the moment if this is implemented in the C++ Libraray, but you may have a look into the Manual.
If not it would be no problem to write the software for binary filecopy

Open Oldfile for readonly
Create Newfile
read Odfile into buffer
write (buffer into newfile)
until Transfer is complete
Delete oldfile id necessary.

hnd
hasso55@yahoo.com

 
Thanks, man - yeah, I guess I'll have to stop being so lazy & copy the things myself.

Cheers,
Douglas JL

If it don't make you laugh, it ain't true.
 
Make it easier : just use CopyFile

BOOL CopyFile(

LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);


There is a help about CopyFile Wim Vanherp
Wim.Vanherp@belgacom.net
 
Cheers, Wimvanherp - that's exactly what I was lokoing for!

Thanks alot,
Douglas Common sense is what tells you the world is flat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top