MoveFile problem
- Juan Carlos
- Posts: 889
- Joined: Mon Sep 06, 2010 1:02 pm
MoveFile problem
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
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
- Juan Carlos
- Posts: 889
- Joined: Mon Sep 06, 2010 1:02 pm
Re: MoveFile problem
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?
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
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:
This would fail with the error message you posted.
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")
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
- Juan Carlos
- Posts: 889
- Joined: Mon Sep 06, 2010 1:02 pm
Re: MoveFile problem
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.
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: MoveFile problem
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.and the second is the destiny only with the directory
- Juan Carlos
- Posts: 889
- Joined: Mon Sep 06, 2010 1:02 pm
Re: MoveFile problem
The problem is that directory to destination is diferent to directory of source even not exist it is new and that error.airsoftsoftwair wrote: ↑Fri Nov 16, 2018 9:29 pmYes, 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.and the second is the destiny only with the directory
- airsoftsoftwair
- Posts: 5433
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: MoveFile problem
Sorry, I don't understand what you mean. Post some code.
- Juan Carlos
- Posts: 889
- Joined: Mon Sep 06, 2010 1:02 pm
Re: MoveFile problem
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
/**** 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
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.
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