Solved

FTP download Bad Sequence Of Commands

Posted on 2013-11-05
1
320 Views
Last Modified: 2013-12-17
Dim fwr As Net.FtpWebRequest = Net.FtpWebRequest.Create(Server)
            fwr.Credentials = New NetworkCredential(UserName, Password)
            fwr.KeepAlive = False
            fwr.Method = WebRequestMethods.Ftp.ListDirectory
            fwr.Proxy = Nothing


            callName(lblDownloading, "Text", CallType.Set, New Object() {"Starting Download"})
            Dim response As FtpWebResponse = fwr.GetResponse
            Dim responseStream As Stream = response.GetResponseStream
            Dim reader = New StreamReader(responseStream)
            Dim Paths As New Collection
            Dim Names As New Collection
            While Not reader.EndOfStream
                Try
                    Dim File As String = reader.ReadLine
                    If File = ".." OrElse File = "." Then Continue While
                    Threading.Thread.Sleep(500)
                    My.Computer.Network.DownloadFile(Server & "/" & File, startedLocation & "\" & File & "1", "Username", "Password", True, 100, True)
                    Paths.Add(startedLocation & "\" & File)
                    Names.Add(File)
                Catch ex As Exception
                    MsgBox(ex.ToString)
                End Try
            End While

            reader.Close()

            responseStream.Close()

            response.Close()
            For i As Integer = 1 To Paths.Count
                Try
                    My.Computer.FileSystem.DeleteFile(Paths.Item(i))
                    My.Computer.FileSystem.RenameFile(Paths.Item(i) & "1", Names.Item(i))
                Catch ex As Exception
                    MsgBox(ex.ToString)
                End Try
            Next

            proc.StartInfo.FileName = startedLocation & "\" & CommandLineArgs(4) & ".exe"

Open in new window


I use this code to run an update command on another program and update from an FTP server.  This code then starts the given program when done updating.  The problem that i am having is on the third file I get an error saying "Bad Sequence Of Commands".  After researching this error, everything said to change the KeepAlive property to false, which I have done but I am still getting the error.  I have tried deleting the third file just to make sure it wasn't a problem with the file itself, and the "new" third file gave the same error.  Any help would be appreciated.
0
Comment
Question by:scprogs
1 Comment
 
LVL 16

Accepted Solution

by:
AlexPace earned 500 total points
ID: 39625064
A network trace would be a big help.

Why not use Ftp.DownloadFile instead of My.Computer.Network.DownloadFile?

Another possibility is to use a Robo-FTP script for the downloads and then start the other program when done using its EXEC command.  The advantage of this is that it can make a trace log that shows all the FTP traffic so it is easier to debug cryptic server responses.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question