Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

FTP download Bad Sequence Of Commands

Posted on 2013-11-05
1
Medium Priority
?
324 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 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

610 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