|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Code only executes on Step Throughlist of files. I plundered the following code from MSDN to accomplish this task. It was part of a class called clsFTP: 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 = "" 'Check 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) 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) ' Console.WriteLine(m_sMes) 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 I connect to the FTP server perfectly. The rest of the functions in that class work great, such as download, upload, etc.. Sadly, GetFileList only returns the first file unless I step through, then it returns everything I have. If I put a break point at the Do While line, then run again, it executes perfectly. If I let it run, it gives me just the first file. The mask I am using is also correct. Any clues??? It is driving me insane. Does the code look tight? I have tried everything I know how. Thanks, Mike I cannot post questions as "new question".
I am installing IIS on my win xp professional. However, there is no IIS listed in the "add/remove windows components". Anybody can help? Thanks "needhelp" <needh***@discussions.microsoft.com> schrieb Use a newsreader like outlook express.> I cannot post questions as "new question". Armin XP doesn't support IIS.
Get a copy of Apache/Tomcat. needhelp wrote: Show quote > I cannot post questions as "new question". > > I am installing IIS on my win xp professional. However, there is no IIS > listed in the "add/remove windows components". Anybody can help? > > Thanks > > John Bailo wrote:
> Oppps.> XP doesn't support IIS. > > Get a copy of Apache/Tomcat. Correction. XP Home doesn't support IIS. Get a copy of Apache/Tomcat. (Are you sure you have XP pro? Do you have the CD?) Show quote > > needhelp wrote: > >> I cannot post questions as "new question". >> I am installing IIS on my win xp professional. However, there is no >> IIS listed in the "add/remove windows components". Anybody can help? >> >> Thanks >> >>
Show quote
"Mike Barrett" <michaelfbarr***@gmail.com> wrote in message No, it does not look correct to me:news:uyR0VBYAGHA.272@TK2MSFTNGP09.phx.gbl... .... > > 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) > ' Console.WriteLine(m_sMes) > If (bytes < m_aBuffer.Length) Then > Exit Do > End If > Loop .... > I connect to the FTP server perfectly. The rest of the functions in that > class work great, such as download, upload, etc.. Sadly, GetFileList only > returns the first file unless I step through, then it returns everything I > have. If I put a break point at the Do While line, then run again, it > executes perfectly. If I let it run, it gives me just the first file. The > mask I am using is also correct. > .... > If (bytes < m_aBuffer.Length) Then This is not good criteria to leave loop as cSocket.Receive does not have to > Exit Do > End If return exact number of bytes that was requested. It can return less. It will return number of bytes currently available (buffered by the OS). In case you run it in debug mode and stop in breakpoint, you are giving network some time to transfer more bytes then m_aBuffer can hold, so Receive will fill whole buffer. Regards, Goran > No, it does not look correct to me: 'Do While (True)> >> If (bytes < m_aBuffer.Length) Then >> Exit Do >> End If > > This is not good criteria to leave loop as cSocket.Receive does not have > to return exact number of bytes that was requested. It can return less. It > will return number of bytes currently available (buffered by the OS). In > case you run it in debug mode and stop in breakpoint, you are giving > network some time to transfer more bytes then m_aBuffer can hold, so > Receive will fill whole buffer. 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) ' Console.WriteLine(m_sMes) 'If (bytes < m_aBuffer.Length) Then 'Exit Do 'End If 'Loop Commenting out the loop returned a perfect value. |
|||||||||||||||||||||||