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!

Moving a file from one location to another

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
How would I move a file, (through c or c++, whatever) from say a CD to a specified location on the hard drive? I only know how to create a file, not move one.

Thanks,
Cyprus
 
To move a file, 1) open the original file, 2) open the new file, 3) copy contents of original file to new file, 4) close both files, 4a) you could then verify that the contents of the two files are the same, 5) delete the original file.

You could also use CreateProcess and use the OS's move command. James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
I am pretty sure you could just call the API function MoveFile or you could use

system(&quot;move <existing file> <new path for file>&quot;);

Matt
 
oh yea, system. But wouldn't it be copy? I thought for sure there was a definate function for doing this though... Cyprus
 
With the cd, yes... move will delete. Missed that part. I only read as far as How do I move a file :)

matt
 
http:\
This is a file copy function. you could make it into a move function by adding the code to delete the source file.

Just to demonstrate some file reading and writing processes.

you dont move from a CD, you copy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top