[Gambas-user] FTPClient - Operation RENAME

Benoît Minisini g4mba5 at gmail.com
Mon Jan 31 19:23:47 CET 2022


Le 31/01/2022 à 13:54, Hans Lehmann a écrit :
> 
> Hello,
> 
> I have the following folder structure on my local FTP server (vsFTPd 
> 3.0.3) with the relevant substructure:
> 
> /k28
> ├── k28.1
> │   ├── k28.1.1
> │   └── k28.1.2
> ├── k28.2
> │   ├── k28.2.1
> │   ├── k28.2.2
> │   └── k28.2.4
> └── k28.3
>      └── k28.3.1
> 
> For renaming the directory k28.2.4 to k28.2.3 I use the following source 
> code(-section) and the FTPClient:
> 
> Public Sub tobtnRenameServerDir_Click()
> 
>      Dim FRename As New FRename
> 
>      Dim sOldDirName, sNewDirName, sText, sCommand, sParamOld, 
> sParamNew, sPath As String
>      Dim aPaths, aBasis As String[]
>      Dim i As Integer
> 
> '-- If there is no selected element, then cancel ...
>      If Not trvServerDirectories.Key Then Return
> 
>      aPaths = Split(trvServerDirectories.Key, "/")
>      sOldDirName = aPaths.Last
>      aPaths.Extract(aPaths.Count - 1)
>      sPath = "/" &/ aPaths.Join("/")
> 
> '-- Dialog for entering the new directory name (Form: FTPRename)
>      sNewDirName = FRename(sOldDirName, ("Rename Server Directory"))
> 
>      sParamOld = sFTPServerInitialPath &/ trvServerDirectories.Key  (= 
> k28/k28.2/k28.2.4)
>      sParamNew = sFTPServerInitialPath &/ sPath &/ sNewDirName      (= 
> k28/k28.2/k28.2.3)
> 
>      Inc Application.Busy
>        hFTPClient.Async = False
>         'hFTPClient.Exec(["RNFR " & noSlash(sParamOld), "RNTO " & 
> noSlash(sParamNew)])   *
>          hFTPClient.Exec(["RENAME " & noSlash(sParamOld) & " " & 
> noSlash(sParamNew)])    **
>          hFTPClient.Async = True
>      Dec Application.Busy
> 
>      If hFTPClient.ErrorText Then
>         Message.Error("The server reports the following error:\n" & 
> hFTPClient.ErrorText)
>      Endif
> 
>      txbServerDir.Text = sPath &/ sNewDirName
> 
>      GetServerList()
>      ShowServerDirectories()
>      ShowServerFiles()
> 
> End
> 
> Private Function noSlash(sValue As String) As String
>      Return IIf(sValue = "/", "", IIf(Left(sValue, 1) = "/", Mid(sValue, 
> 2), sValue))
> End
> 
> Renaming the directory always ends with an error:
> 
> *
> The server reports the following error:
> Access denied to remote resource
> 
> But the directory is renamed anyway! Strange!?
> 
> **
> The server reports the following error:
> Quote command returned error
> 
> The directory will NOT be renamed!
> 
> Where is the error?
> 
> With kind regards
> 
> Hans
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

No idea. Do you have the same errors if you use the "curl" command 
directly? (The Gambas 'FtpClient' is the FTP client of the libcurl library).

-- 
Benoît Minisini


More information about the User mailing list