0

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
Off The Gold
  • 1,228
  • 15
  • 28

1 Answers1

0

It looks like you're running into the 260-character path length limit imposed by Windows (and which doesn't affect your Unix server).

I mention this because you make special note that the error is not reproducible in a development environment (which are typically local to the developer's machine and therefore unlikely to be deeply nested in the directory structure)

It may be that you will have to rename the files on the Unix server, such that their full paths come to less than 260 characters in Windows, before you can do anything with them using this code.

Psychemaster
  • 876
  • 10
  • 20
  • I don't think I am hitting the limit as my file path is only 52 chars and the max file name we have is 75 characters. – Off The Gold Oct 21 '14 at 15:27
  • - Also I should point out our development server has the same path structure as production and the application runs fine on development. – Off The Gold Oct 21 '14 at 15:35
  • In the end the problem was in lower level code, and I had to add a couple ms of sleep for it to work. – Off The Gold Jan 12 '15 at 19:20