Windows Develop Bookmark and Share   
 index > Windows Forms General > sending FTP command to get file list
 

sending FTP command to get file list

 

hello

When recieving a File list from a remote server, is there any way to differentiate files from directories in the list. If not, what would be the best way?

This is the code I'm using:

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
Dim sItem As String
Dim str As String

m_sMes = ""

'Check to see if you are logged on to the FTP server.

If (Not (m_bLoggedIn)) Then
Login()
End If

 cSocket = CreateDataSocket()

'Send an FTP command.
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)
m_aBuffer.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

ones81  Thursday, January 12, 2006 10:24 AM
Try usign the "dir" command.
ThE_lOtUs  Thursday, January 12, 2006 4:04 PM

You can use google to search for other answers

Custom Search

More Threads

• how can i save the text format to the database?
• formatting excel cells dynamically using vb.net express 2005
• DatagridView combobox selection change
• Alert Box
• not able to connect with the same server through INTERNET using TCP/IP
• Form.Enabled = False resizes form..
• font color changing
• Whats going on with the tabpage alignment error??
• LicenseProvider equivalent for an entire assembly
• How to create descriptions in IDE popups, and Object Browser