MoveFile problem

Find quick help here to get you started with Hollywood
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

MoveFile problem

Post 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?
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: MoveFile problem

Post by Clyde »

It would be helpful if you would post the error (message) you get.
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Re: MoveFile problem

Post 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?
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: MoveFile problem

Post 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.
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Re: MoveFile problem

Post 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.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: MoveFile problem

Post 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.
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Re: MoveFile problem

Post 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.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: MoveFile problem

Post by airsoftsoftwair »

Sorry, I don't understand what you mean. Post some code.
User avatar
Juan Carlos
Posts: 887
Joined: Mon Sep 06, 2010 1:02 pm

Re: MoveFile problem

Post 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
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: MoveFile problem

Post 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.
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
Post Reply