Solved

FTP download Bad Sequence Of Commands

Posted on 2013-11-05
1
322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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