Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.5k views
in .NET FTP by (600 points)
Ok This is weird I know I have aministrative right and this should not be happening. I try to download a file from the remote server to my PC and I get an access denied error. It must be something in the download sub procedure I will post it here. I f you see something incorrect could you please let me know.
 Try
            eFTPConnection = New FTPConnection
            'Get the selected item(s) from the FTP server if any
            If lvFiles.SelectedItems.Count > 0 Then
                'Use folder browser to select the download directory
                Dim fb As New FolderBrowserDialog
                fb.ShowDialog()
                'Ensure that the selected path is not null
                If Not fb.SelectedPath Is Nothing Then
                    DirListBox1.Path = fb.SelectedPath
                    FileListBox1.Path = DirListBox1.Path
                    Dim lvItem As ListViewItem
                    For Each lvItem In lvFiles.SelectedItems
                        'Set the variables for downloading
                        RemoteFile = lvItem.Text
                        LocalPath = fb.SelectedPath
                        ConnectToServer()
                        eFTPConnection.DownloadFile(LocalPath, RemoteFile)
                        ProgressBar1.Maximum = CInt(eFTPConnection.TransferBufferSize)
                        'Loop while transferring and pass the value to the progressbar
                        Do While eFTPConnection.IsTransferring
                            ProgressBar1.Value = CInt(eftpTransferBytes.ByteCount)
                        Loop
                    Next
                End If
            End If
            eFTPConnection.Close()
        Catch ex As Exception
            txtResponse.Text = vbCrLf & ex.Message
        End Try

I get the following error message
       txtResponse.text = Access denied C:\.......\.....

11 Answers

0 votes
by (162k points)
What is the local path you are passing in?

Ok This is weird I know I have aministrative right and this should not be happening. I try to download a file from the remote server to my PC and I get an access denied error. It must be something in the download sub procedure I will post it here. I f you see something incorrect could you please let me know.
.
0 votes
by (51.6k points)
Could it be that this code is being executed by a user other than what you are expected? For example, Windows Services are run as the SYSTEM user by default. You can use the System.Environment.UserName property to check.

- Hans (EDT)
0 votes
by (600 points)
Path and error message copied fro textbox:
Access to the path 'C:\Documents and Settings\Owner\Desktop\Code' is denied.
Note I have tried different paths with no luck.
Result from msgBox on form load:
MsgBox(System.Environment.UserName)
Owner
Owner which is me has full administrative rights. From reading around I see that you sometimes ask to try a different FTP Client could you reccomend one for testing so I dont have to search the forum? This way I can test if its on my end or not.
0 votes
by (51.6k points)
Try FileZilla.

Also, try to create a file manually using System.IO.File.Create("filename"); that's how we create them in edtFTPnet, so there shouldn't be any difference between us doing it inside edtFTPnet and you doing it yourself.

- Hans (EDT)
0 votes
by (600 points)
System.IO.File.Create("C:\filename.zip") Works OK created the zip file in C:\
I will try another client after dinner and repost Thanks Dwain
0 votes
by (600 points)
FtpWanderder Client I had and it downloads files to my PC OK now what? I was just thinking the ftp client I used brought up a firewall message asking if it was ok to unblock the transfer. My code did not bring up the firewall message I wonder if the firewall is blocking the transfer?
Do you know of any way to test that theory? Nope shut off the firewall and still access denied.
I took out all unneeded commands to simplify the process
1) Connect To The server
2) Retrieve the filename from the list view (Verify that it was correct)
3) DownloadFile("C:\", RemoteFile) Remote filename was taken from the above listview
4) Close the connection

I went to the firewall and added ftpclient.exe to the list just in case.
Still access denied as above. I am just about out of thoughts on this.
0 votes
by (51.6k points)
Why don't you try using DownloadByteArray() or DownloadStream() to download the file into a temporary buffer and then write the buffer to the file yourself? This will isolate the file-writing from the FTP transfer. Also, since you have the source-code, you could try to include it in your project and step through it in a debugger to see if you can narrow down the problem.

- Hans (EDT)
0 votes
by (700 points)
3) DownloadFile("C:", RemoteFile) Remote filename was taken from the above listview


Isn't the file name required as part of the local path in DownloadFile()? For example:
DownloadFile("C:\filename.zip", "filename.zip")

In your example, your local path was only "C:" with no file name specified. Could this be why it is failing?

(5/30/2006 6:49am EST) EDIT:
Also, in your initial example you have:
eFTPConnection.DownloadFile(LocalPath, RemoteFile)

Perhaps you need:
eFTPConnection.DownloadFile(LocalPath + RemoteFile, RemoteFile)

Note that depending on your variables, you may need to add a backslash in between the LocalPath and RemotePath for the local path portion of DownloadFile().
0 votes
by (162k points)
Thanks Boz, that does look like the problem here.
0 votes
by (600 points)
Thanks that did the trick I assumed by passing the path and the remote filename that the control would put them together. Thanks to everyone for their help. Dwain.

Categories

...