Solved

FTP download Bad Sequence Of Commands

Posted on 2013-11-05
1
307 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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WPF issue with Trigger 2 65
Converting C# Objects into JSON file 7 35
Expando 4 33
Set form below another form 3 25
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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now