Solved

FTP download Bad Sequence Of Commands

Posted on 2013-11-05
1
321 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 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