473,239 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 software developers and data experts.

ftp question using article id 832679

ps
I am using this article to get a list of files in a directory using ftp.
If I run the code without some kind of delay, I only get about half the
files. If I put a debug.write statement it returns all the files. I think
this may be some kind of timing issue. Can anyone help?
URL:http://support.microsoft.com/?scid=kb;EN-US;832679
Here are the two sections of code that I am using:

'Return a list of files from the file system. Return these files in a
string() array.

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 strCmd As String

If sMask Is Nothing Then

strCmd = "NLST"

'strCmd = "LIST"

Else

strCmd = "NLST " & sMask

End If

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)

SendCommand(strCmd)

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)

Debug.Write(ASCII.GetString(m_aBuffer, 0, bytes)) 'this will
affect the number of files returned. Maybe a timing issue?

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

Private Sub cmdRun_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdRun.Click

Dim strFileList() As String

Try

'URL:http://support.microsoft.com/?scid=kb;EN-US;832679

ftpServer = New xxxFTP.clsFTP("IP Address", ".", "userId",
"password", 21)

If ftpServer.Login() Then

MessageBox.Show("sucessful login")

'strFileList length will be 88 (files) without the debug.write
statement and 157 with the debug statement

strFileList = ftpServer.GetFileList(Nothing) 'no mask

'strFileList = ftpServer.GetFileList("*.*") 'only files with
extension

Me.lstFiles.Items.Clear()

Dim str As String

For Each str In strFileList

If str.Trim <> "." And str.Trim <> ".." Then

Me.lstFiles.Items.Add(str)

End If

Next

Else

MessageBox.Show("unsucessful login")

End If

Catch ex As Exception

MessageBox.Show(ex.ToString)

Finally

ftpServer.CloseConnection()

End Try

End Sub
Jul 21 '05 #1
0 1998

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
1
by: Rajesh S | last post by:
Hi, Is anybody is know how to distingush a directoryname and filename from the list we obtain by giving FTP Command "NLST".? I am using a class as per the micosoft document...
4
by: Steve Richter | last post by:
can File.Copy be use to copy files from my PC to the file system at my shared hosting web site? If so, what is the format of the path name of the file on the web site? The idea being that if I...
5
by: Tim Smallwood | last post by:
I have a program I'm wanting to write that will open an accounting program, do a back up (This functionality is buiilt into this accounting program) and then take the backup file that is a result...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
0
by: ps | last post by:
I am using this article to get a list of files in a directory using ftp. If I run the code without some kind of delay, I only get about half the files. If I put a debug.write statement it returns...
1
by: Joris De Groote | last post by:
Hi, I'm using in a VB.NET program a few links to other computers to write or read from (\\192.168.2.5\Filez\ for example), now I have to go to that folder first and log in, otherwise, the...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
6
by: John Larson | last post by:
Hi All, I am some information from INSPEC database records in XML to build a relational database of my own. I am currently trying to extract information by doing an XSLT transform of the XML...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.