Welcome to the Xceed Community | Help
Community Search  
More Search Options

CopyTo folder error on VAX (NEED HELP)

Sort Posts: Previous Next
  •  10-06-2006, 3:05 PM Post no. 5160

    CopyTo folder error on VAX (NEED HELP)

    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
  •  10-25-2006, 1:35 PM Post no. 5161 in reply to 5160

    Re: CopyTo folder error on VAX (NEED HELP)

    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>

    André
    Software Developer
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.