Page 1 of 2

MoveFile problem

Posted: Tue Nov 13, 2018 7:17 am
by Juan Carlos
I tried to use this new function using as base the copy routines even with callback function but it gives me problem with erro/wrong use the parameters, someone test this?

Re: MoveFile problem

Posted: Tue Nov 13, 2018 8:41 am
by Clyde
It would be helpful if you would post the error (message) you get.

Re: MoveFile problem

Posted: Tue Nov 13, 2018 6:26 pm
by Juan Carlos
MoveFile(FicheroCopiar$, DestinoCarpeta$, p_MonitorizarMover)
Where FicheroCopiar$ is the string with the file and path of source, DestinoCarpeta$ the destiny path and callback function to move the file.
The message: Wrong usage/parameters for this command!
The routine is the same than copy and this works fine. Where is the problem?

Re: MoveFile problem

Posted: Wed Nov 14, 2018 10:08 pm
by Clyde
This function works for me. You have to pay attention to this sentence in the documentation: "Note that dst$ must not exist or MoveFile() will fail."
That means, if you already have a file called hello2.txt in your destination folder and you call:

Code: Select all

MoveFile("hello.txt", "hello2.txt")
This would fail with the error message you posted.

Re: MoveFile problem

Posted: Thu Nov 15, 2018 10:16 am
by Juan Carlos
The two hello strings I give the source with file and directory and the second is the destiny only with the directory. It hasn't problem or the instruction doesn't work with strings with paths.

Re: MoveFile problem

Posted: Fri Nov 16, 2018 9:29 pm
by airsoftsoftwair
and the second is the destiny only with the directory
Yes, and that is the problem. As Clyde said, the destination mustn't be anything that already exists. If you pass a directory name, then this obviously exists so make sure you append the filename to that directory and it will work.

Re: MoveFile problem

Posted: Sat Nov 17, 2018 9:59 am
by Juan Carlos
airsoftsoftwair wrote: Fri Nov 16, 2018 9:29 pm
and the second is the destiny only with the directory
Yes, and that is the problem. As Clyde said, the destination mustn't be anything that already exists. If you pass a directory name, then this obviously exists so make sure you append the filename to that directory and it will work.
The problem is that directory to destination is diferent to directory of source even not exist it is new and that error.

Re: MoveFile problem

Posted: Sat Nov 17, 2018 12:54 pm
by airsoftsoftwair
Sorry, I don't understand what you mean. Post some code.

Re: MoveFile problem

Posted: Sun Nov 18, 2018 12:44 pm
by Juan Carlos
Here is the code:
/**** FUNCIÓN MOVER GRÁFICO ****/
Function p_MoverGrafico()
FicheroCopiar$=FileCopy$ ;Here is FileCopy$=LaRuta$..Grafico$ from LaRuta$=PathPart(Imagen$) and Grafico$=FilePart(Imagen$)
;The image with its path

DestinoCarpeta$=PathRequest("Where you want to move the picture")
If(DestinoCarpeta$="") ;Here you ask the destinity directory to move the file, it has exists.
SystemRequest("Drawer not exist", "Destination drawer is not correct", "OK")
Return()
Else
MoveFile(FicheroCopiar$, DestinoCarpeta$, p_MonitorizarMover)
EndIf
EndFunction
Function p_MonitorizarMover(msg)
Switch msg.action
Case #MOVEFILE_UNPROTECT:
Return(SystemRequest(" Test Move", FilePart(msg.destination).." already exist!\n"..
"Do you want overwrite it?", "OK"))
Case #MOVEFILE_DELETE:
Return(SystemRequest(" Test Move", FilePart(msg.destination).." already exist!\n"..
"Do you want overwrite it?", "OK"))
Case #MOVEFILE_COPY:
Return(SystemRequest(" Test Move", FilePart(msg.destination).." already exist!\n"..
"Do you want overwrite it?", "OK"))
EndSwitch
EndFunction

Re: MoveFile problem

Posted: Sun Nov 18, 2018 2:13 pm
by Clyde
Ok, two things:

1. The callback function (p_MonitorizarMover) is just called, when you move a file from one partition to another. It is not called if you move the file within a partition (if I understood it correctly).

2. Let's say you want to move the file "hello.txt" to the folder "my_documents". You _cannot_ call MoveFile() like this:
MoveFile("hello.txt", "my_documents/")

Instead, you have to call it this way:
MoveFile("hello.txt", "my_documents/hello.txt")

This means you _have to_ specify the name of the file in the destination folder.