Home Forums .NET libraries Xceed SFTP/FTP for .NET CopyTo folder error on VAX (NEED HELP)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20807 |

    I am trying to send a file to VAX. This routine works for Windows FTP servers. On VAX, I get the error below when I run the following line:

    dfSunData.CopyTo(dirFTPRoot, True)

    dfSunData is a text file.

    “Xceed.FileSystem.FileSystemException: An error occurred while creating a folder.
    Type: Xceed.Ftp.FtpFolder
    FullName: \$DISK2:[STAN]\ —> Xceed.Ftp.FtpReplyException: Directory “$DISK2:[STAN]” already exists. (reply code 550)
    at Xceed.Ftp.Engine.FtpCommand.EndExecute(IAsyncResult asyncResult)
    at Xceed.Ftp.Engine.FtpCommand.Execute(FtpCommandChannel commandChannel)
    at Xceed.Ftp.FtpClient.CreateFolder(String folder)
    at Xceed.Ftp.FtpFolder.DoCreate(FileSystemEventsSession session)
    The FTP reply was:
    550 Directory “$DISK2:[STAN]” already exists.

    — End of inner exception stack trace —
    at Xceed.FileSystem.FileSystemItem.CopyTo(FileSystemEvents events, Object userData, AbstractFolder destinationFolder, Boolean replaceExistingFiles)
    at Xceed.FileSystem.FileSystemItem.CopyTo(AbstractFolder destinationFolder, Boolean replaceExistingFiles)
    at FTPExportOrders.clsFTP.FTPPutOrders(MyFTPFile FTPStruct)”

    Here is the code:

    Public Sub FTPPutOrders(ByVal FTPStruct As MyFTPFile)
    Dim strNewName As String
    ‘FTP root folder
    Dim dirFTPRoot As AbstractFolder

    If File.Exists(FTPStruct.LocalFileName) Then
    Try
    cnnFTP = New FtpConnection(FTPStruct.IPAddress, 21, FTPStruct.userID, FTPStruct.password)
    dirFTPRoot = New FtpFolder(cnnFTP)

    Catch exFTP As Exception
    Try
    cnnFTP = New FtpConnection(FTPStruct.IPAddress, 21, FTPStruct.userID, FTPStruct.password)
    dirFTPRoot = New FtpFolder(cnnFTP)
    Catch ex As Exception
    Call WriteFTPLog(“FTP Connection failed in FTPExportOrders, Could not PUT ” & FTPStruct.LocalFileName & ” to ” & FTPStruct.IPAddress)
    Call HandleErrors(gstrJobName, “FTPPutOrders()”, gstrLogPath, ex.ToString, False, False, False, “FTP Connection failed to ” & FTPStruct.IPAddress)
    Exit Sub
    ‘SendMail(gstrFromAddr, gstrToAddr,”ERROR-FTPExportOrders – “,exFTP.ToString)

    End Try
    ‘Catch ex As ftException
    ‘ Call HandleErrors(gstrJobName, “FTPPutOrders()”, gstrLogPath, ex.ToString, False, False, False, “FTP Connection failed to ” & FTPStruct.IPAddress)
    ‘ Exit Sub
    End Try

    ‘Set local folder path
    ‘Maybe need just path
    Dim dfSunData As DiskFile = New DiskFile(FTPStruct.LocalFileName)
    Try
    dfSunData.CopyTo(dirFTPRoot, True)
    Call WriteFTPLog(“FTP to ” & FTPStruct.IPAddress & ” successful”)
    If FTPStruct.RenameFile Then
    strNewName = FTPStruct.LocalFileName.Replace(“.”, “_” & Date.Now.ToString(“yyyyMMdd_hhmmss”) & “.”)
    strNewName = strNewName.Substring(strNewName.LastIndexOf(“\”) + 1)
    File.Copy(FTPStruct.LocalFileName, gstrBackupDir & strNewName, True)
    File.Delete(FTPStruct.LocalFileName)
    End If
    ‘Catch exFTP As FtpException
    ‘ Call WriteFTPLog(“FTP Connection failed in FTPExportOrders, Could not PUT ” & FTPStruct.LocalFileName & ” to ” & FTPStruct.IPAddress)
    ‘ Call HandleErrors(gstrJobName, “FTPPutOrders()”, gstrLogPath, exFTP.ToString, True, False, True)
    Catch ex As Exception
    Call WriteFTPLog(“FTP Connection failed in FTPExportOrders, Could not PUT ” & FTPStruct.LocalFileName & ” to ” & FTPStruct.IPAddress)
    Call HandleErrors(gstrJobName, “FTPPutOrders()”, gstrLogPath, ex.ToString, False, False, False)
    Finally
    cnnFTP.CloseConnections()
    End Try
    End If

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Mike R (had 3530 views)

    User (Old forums)
    Member
    Post count: 23064

    The format for the file/folder structure on the FTP server is very different from Windows format, and since Xceed FileSystem classes are based on Windows format, it is not compatible with this format. This why there is an exception thrown in the CopyTo method.

    In short, FileSystem does not support the listing format employed by the server, but it is supported by FtpClient. So the workaround to the problem is to use the FtpClient classes instead of the FileSystem classes.

    e.g.:
    <i>
    FtpClient ftpConn = new FtpClient();

    ftpConn.Connect( “server” );
    ftpConn.Login( “user”, “password” );

    ftpConn.SendFile( @”D:\test.txt” );

    FtpItemInfoList fileList = ftpConn.GetFolderContents( “*.txt;*.zip” );
    foreach( FtpItemInfo file in fileList )
    {
    Console.WriteLine( file.Name );
    }

    ftpConn.Disconnect();
    </i>

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 4199 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.