So I have a vb.net application, running on a windows server, that has an ftp class that we call to interact with our files on our unix server. The application had been running fine for years, until we started interacting with a large group (~130 PDFs) of files. Then suddenly file names would get cuttoff when we tried to delete them.
The error we are seeing when trying to delete the file "a839084_gaa13-132_tower-j34-aspect-localization-specification-jd345.pdf"
"550 a839084_gaa13-132_tower-j34-aspect-locali: A file or directory in the path name does not exist."
Below is an example how we call it and the function is listed below it. Any idea on how to improve this code so it doesn't occur again? I think the problem is showing when we try to Split() the text. Another bizarre thing is that this error isn't always re-producible. When I put the same set of files on our development server I don't get the error.
...
' Read the Remote list into an array
Dim RemList() As String = ftpConnObj.GetFileList("*.pdf")
Dim i As Object
'loop through each file in the array and delete the Remote file.
For Each i In RemList
If i.ToString.Trim.Length > 0 Then
Try
ftpConnObj.DeleteFile(i.ToString.Trim)
connMsg = ftpConnObj.MessageString
...
' Return a list of files within a string() array from the
' file system.
Public Function GetFileList(ByVal sMask As String) As String()
Dim cSocket As Socket
Dim bytes As Int32
Dim seperator As Char = ControlChars.Lf
Dim mess() As String
m_sMes = ""
If (Not (m_bLoggedIn)) Then
Login()
End If
cSocket = CreateDataSocket()
SendCommand("NLST " & sMask)
If (Not (m_iRetValue = 150 Or m_iRetValue = 125)) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
m_sMes = ""
Do While (True)
Array.Clear(m_aBuffer, 0, m_aBuffer.Length)
bytes = cSocket.Receive(m_aBuffer, m_aBuffer.Length, 0)
m_sMes += ASCII.GetString(m_aBuffer, 0, bytes)
If (bytes < m_aBuffer.Length) Then
Exit Do
End If
Loop
mess = m_sMes.Split(seperator)
cSocket.Close()
ReadReply()
If (m_iRetValue <> 226) Then
MessageString = m_sReply
Throw New IOException(m_sReply.Substring(4))
End If
Return mess
End Function