Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.3k views
in .NET FTP by (400 points)
for some reason i just can't get a button to download a file

here is the code

Private Sub btnMvClan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMvClan.Click

        Try
            FtpConnection1.Timeout = 3000
            FtpConnection1.ServerDirectory = "/wwwroot/admin/importfiles"
            FtpConnection1.Connect()
            FtpConnection1.DownloadFile("c:\temp\", lstRemoteStock.SelectedItem.ToString)
            FtpConnection1.Close()

        Catch ex As Exception
            If FtpConnection1.IsConnected Then
                FtpConnection1.Close()
            End If
            MessageBox.Show(Me, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try

    End Sub


All i get when i click on button is
Could not find part of the path c:\temp

I need to download the file to the pc ready to be uploaded to a different directory (i.e. move the file)

4 Answers

0 votes
by (400 points)
In fact has anyone got an application that uploads and downloads files using edtftpnet free? that they would like to share so i could use it as a example/tutorial?

Sorry but i'm a complete newbie to .net and vb and i'm trying to run before i can even crawl lol
0 votes
by (51.6k points)
I think your problem is that you are not specifying the local file fully. You should specify the full local file-name, not just the directory. Try something like this:
Private Sub btnMvClan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMvClan.Click

        Try
            FtpConnection1.Timeout = 3000
            FtpConnection1.ServerDirectory = "/wwwroot/admin/importfiles"
            FtpConnection1.Connect()
            Dim fileName As String = Path.GetFileName(lstRemoteStock.SelectedItem.ToString())
            FtpConnection1.DownloadFile("c:\temp\" & fileName, lstRemoteStock.SelectedItem.ToString())
            FtpConnection1.Close()

        Catch ex As Exception
            If FtpConnection1.IsConnected Then
                FtpConnection1.Close()
            End If
            MessageBox.Show(Me, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try

End Sub


Before you ask, I believe the next version of edtFTPnet (to be released soon), will automatically append the file-name if the localFile argument to DownloadFile specifies a directory.

- Hans (EnterpriseDT)
0 votes
by (400 points)
Do you have an ETA on the new version?

If it's not too long i may wait until that is released before doing any more work on the application
0 votes
by (162k points)
Plan is by about the end of May or so - about a week.

Categories

...