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