[Gambas-user] Move ... Kill function (File & Directory Functions)
Tony Morehen
tmorehen at ajm-software.com
Sun Sep 23 16:53:02 CEST 2018
A note of caution:
Move cannot move a file between drives. It fails with error code 38
System error #18: Invalid cross-device link. In such a case, you must
copy the file then delete the source.
I'm not sure what happens in such a case with Move...Kill. Does the
Kill destination happen before the error? Is that a problem?
On 2018-09-23 9:34 a.m., Hans Lehmann wrote:
> Hello Fabien,
>
> thank you so much for your answer.
> Here is the modified and verified source code:
>
> Public Sub btnMoveKill_Click()
>
> Dim sSourcePath, sDestinationPath, sFilename As String
>
> sSourcePath = User.Home &/ "DW"
> sDestinationPath = User.Home &/ "GB3BUCH"
> sFileName = "dokuwiki_syntax.txt"
>
> ' Check whether the file to be moved exists.
> If Exist(sSourcePath &/ sFileName) Then
> ' Now check if moveto directory exists
> If Not Exist(sDestinationPath) Then
> Try Mkdir sDestinationPath
> If Error Then
> Message.Error("Error! " & Error.Text)
> Return
> Endif
> Endif
> ' Now the file is moved
> Move sSourcePath &/ sFileName Kill sDestinationPath &/ sFileName
> Else
> Message.Error("File not exist: " & sFileName)
> Return
> Endif
>
> Message.Info("File '" & sFileName & "' successfully moved!")
>
> End
>
> Hans
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
More information about the User
mailing list