Hello.
i need to move a file form one location to another....
what apis woudl i need to do this?
and if u can make it low levelish....so if ther is 1 api that does the work of 5...i woudl rally rather know the 5 then the 1.
:P
thx
Posted on 2004-09-14 15:03:33 by ReVeR
#1: MoveFile{Ex}
#2: 2xCreateFile, loop:{ReadFile, WriteFile}, 2xCloseHandle, DeleteFile
Posted on 2004-09-14 15:39:37 by f0dder
sorry fro teh dumb questoin but i am nto sure what doesn;t work...hereis the code:


.386
.model flat, stdcall
option casemap :none

include windows.inc
include kernel32.inc
include user32.inc
include Comctl32.inc
include shell32.inc

includelib kernel32.lib
includelib user32.lib
includelib Comctl32.lib
includelib shell32.lib

.data
from db "main.exe",0
to db "C:\",0

.code
start:
invoke MoveFile,addr from,addr to
invoke ExitProcess,NULL
end start


the progrma deosn't mov the main.exe to c:\.....the main,exe is in the same folder as the mover program.....
am i missing someting?
i also tried to ahve the to as c:\main.exe....
didn't work either....
any ideas?
Posted on 2004-09-14 16:15:56 by ReVeR
Perhaps a dumb question, but is main.exe located on drive C:?
Posted on 2004-09-14 16:19:36 by f0dder
no it is not, main.exe and mover.exe are on the desktop
i want mover to move the main.exe to c:\ ,
but for some reasont he above code dones't do that.
so they are in the c drive, but not in the rot directory of the c
any ideas?
Posted on 2004-09-14 16:41:34 by ReVeR
Well, "on drive C" means "anywhere on drive C", not "the root of drive C" - I asked the question since one of the requirements of MoveFile is that source and destination are on the same drive.

Try running in OllyDbg and check LastError after the MoveFile?
Posted on 2004-09-14 16:48:47 by f0dder
weee..i am not too sure how to use olly dbg..can someone give me a couple of tuts on that?
cuz i know nothing more then how to search for strings.....
:?
Posted on 2004-09-14 16:53:46 by ReVeR
main.exe has to be in the same directory as your program
change


to db "C:\",0

into


to db "C:\main.exe",0
Posted on 2004-09-14 16:57:21 by Mikky
He already tried the "c:\main.exe", and MoveFile specifies that you can specify a directory as target, so it ought to work...
Posted on 2004-09-14 17:02:05 by f0dder
ok, i think i got it to work...i didn't recompile it...stupid me
but how woudl i go about moving a file form 1 drive to another?
Posted on 2004-09-14 17:07:51 by ReVeR
MoveFileEx can handle that, but is only supported on NT - so you'll have to use the algorithm I outlined earlier.
Posted on 2004-09-14 17:15:03 by f0dder
... I asked the question since one of the requirements of MoveFile is that source and destination are on the same drive.

MoveFile() will fail only when you move a directory across volumes, not files.
Posted on 2004-09-14 18:01:18 by death
Sorry for that one, I read through PSDK too quickly :)
Posted on 2004-09-14 18:05:43 by f0dder