MoveFile problem

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

MoveFile problem

Post by Juan Carlos » Tue Nov 13, 2018 7:17 am

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: 113
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: MoveFile problem

Post by Clyde » Tue Nov 13, 2018 8:41 am

It would be helpful if you would post the error (message) you get.
Currently using: Hollywood 7.1 with Windows IDE

User avatar
Juan Carlos
Posts: 452
Joined: Mon Sep 06, 2010 1:02 pm
Location: Palencia
Contact:

Re: MoveFile problem

Post by Juan Carlos » Tue Nov 13, 2018 6:26 pm

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: 113
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: MoveFile problem

Post by Clyde » Wed Nov 14, 2018 10:08 pm

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 7.1 with Windows IDE

User avatar
Juan Carlos
Posts: 452
Joined: Mon Sep 06, 2010 1:02 pm
Location: Palencia
Contact:

Re: MoveFile problem

Post by Juan Carlos » Thu Nov 15, 2018 10:16 am

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: 2670
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: MoveFile problem

Post by airsoftsoftwair » 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.

User avatar
Juan Carlos
Posts: 452
Joined: Mon Sep 06, 2010 1:02 pm
Location: Palencia
Contact:

Re: MoveFile problem

Post by Juan Carlos » Sat Nov 17, 2018 9:59 am

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: 2670
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: MoveFile problem

Post by airsoftsoftwair » Sat Nov 17, 2018 12:54 pm

Sorry, I don't understand what you mean. Post some code.

User avatar
Juan Carlos
Posts: 452
Joined: Mon Sep 06, 2010 1:02 pm
Location: Palencia
Contact:

Re: MoveFile problem

Post by Juan Carlos » Sun Nov 18, 2018 12:44 pm

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: 113
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: MoveFile problem

Post by Clyde » Sun Nov 18, 2018 2:13 pm

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 7.1 with Windows IDE

Post Reply