[Gambas-user] Move ... Kill function (File & Directory Functions)

Fabien Bodard gambas.fr at gmail.com
Sun Sep 23 16:48:03 CEST 2018


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
   Message.Error("File not exist: " & sFileName)
   Return
  Endif

  Move sSourcePath &/ sFileName Kill sDestinationPath &/ sFileName

  Message.Info("File '" & sFileName & "' successfully moved!")

End


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.

  Move sSourcePath &/ sFileName Kill sDestinationPath &/ sFileName
  Message.Info("File '" & sFileName & "' successfully moved!")

Catch
  Message.Error(Error.Text)
End


i think the second way can do the job too but i've not tested it yet

Le dim. 23 sept. 2018 16:35, Hans Lehmann <hans at gambas-buch.de> a écrit :

> 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 ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180923/07fa7f70/attachment-0001.html>


More information about the User mailing list