login about faq

"Access is Denied" error occurs when attempting to download a file from a FTP site. Connection to the site is successful. What is denied? The file on the ftp or the folder where the file is to be downloaded?

If it's a permissions issue, then why is connecting to the site successful?

Code: Dim extractPath As String = "xxx"

    If Not Directory.Exists(extractPath) Then
    End If

    Dim ftp As New Chilkat.Ftp2

    Dim success As Boolean
    success = ftp.UnlockComponent("cccc")

    If (success <> True) Then
        FTPFailure(ftp.LastErrorText, String.Empty)
        ftp.Hostname = "xxx"
        ftp.Username = "yyy"
        ftp.Password = "zzz"

        '  Connect and login to the FTP server.
        success = ftp.Connect()
        If (success <> True) Then
            FTPFailure(ftp.LastErrorText, String.Empty)
            Exit Sub
        End If

        '  Change to the remote directory where the file will be uploaded.
        success = ftp.ChangeRemoteDir("/")
        If (success <> True) Then
            FTPFailure(ftp.LastErrorText, String.Empty)
            Exit Sub
        End If

        '  Download file to extractPath
        success = ftp.GetFile("aaa-bbb.png", extractPath)
        If (success <> True) Then
            FTPFailure(ftp.LastErrorText, String.Empty)
            Exit Sub
        End If
    End If

The folder is accessible on this computer thru windows explorer. Thanks for any help or advice.

asked Aug 18 '17 at 16:03

eam's gravatar image


You should probably post the lastErrorText you get after ftp.GetFile. Perhaps first set the VerboseLogging option, see http://cknotes.com/the-basic-concept-of-lasterrortext/

(Aug 19 '17 at 02:51) Gert ♦

Sorry for my late response. Here is lastErrorText:

DllDate: Aug 26 2015
UnlockPrefix: ISSVCCFTP
Username: aaa:bbb
Architecture: Little Endian; 32-bit
Language: .NET 4.0
VerboseLogging: 1
enabled: yes
heartbeatMs: 0
sendBufferSize: 65536
localFilename: C:\xxx\Images\unzipped
Replacing existing local file
WindowsError: Access is denied.
WindowsErrorCode: 0x5
win32CreateFileAnsi failed.
localFilePath: C:\xxx\Images\unzipped
currentWorkingDirectory: C:\ddd\eee\fff\bin\Debug
localWindowsFilePath: C:\xxx\Images\unzipped

answered Aug 28 '17 at 18:06

eam's gravatar image


edited Aug 28 '17 at 19:03

jpbro's gravatar image

jpbro ♦

Is this a permissions issue? I've tried other ftp sites and have the same problem. However, I can upload to any site. I cannot download from any site.

I'm not sure what to tell my IT administrator what I need to be able to download. I need permissions....to what?



answered Aug 29 '17 at 09:42

eam's gravatar image


This is a local file creation error! "win32CreateFileAnsi failed."  
does the full path "C:\xxx\Images\unzipped" Exist?  
shouldn't there be a trailing "\"  
can your program create a "text" file in the above folder with out Chilkat, Using native code?  
try this code  
dim FF as long  
Open "C:\xxx\Images\unzipped\TEST.TXT" For Output Lock write As FF   ' Note Trailing backslash in path  
Write #FF, "This is just a dummy test file."  
close FF

if that code creates the test.txt file without error then it's the "\"   
if you get a permission error then you don't have the right to create/write data to that folder.  
and the error/problem is not a CHILKAT error  

answered Aug 29 '17 at 20:29

rgibson's gravatar image


edited Aug 30 '17 at 01:36

I added this code:
Dim testThis As String = "C:aaaimagesunzippedtest.txt" File.WriteAllText(testThis, String.Empty) Dim sw As New StreamWriter(testThis, False) sw.WriteLine(testThis) sw.Close()

text.txt was created in the folder.

Slashes don't display correctly here. Where there is a dash, there is actually a slash: C:-aaa-images-unzipped-text.txt

(Aug 30 '17 at 09:12) eam

update to above.

I added code to verify that "aaa-bbb.png" exists on the FTP site. The code was successful in finding it on the site.

I can create a txt file in the folder on C.

So the problem appears to be the ftp.GetFile command.

(Aug 30 '17 at 09:48) eam

Ah, got it.

Replaced "success = ftp.GetFile("aaa-bbb.png", extractPath)" with "success = ftp.GetFile("aaa-bbb.png", extractPath & 'aaa-bbb.png')"

Just referencing the path is not enough. The file name must also be included.

Thanks to all who took the time to reply.

(Aug 30 '17 at 10:45) eam

I just noticed in your LastErrorText that the localfilename has no filename part
"localFilename: C:/xxx/Images/unzipped"
also the forum understandably does not like backslashes.
whats the value of extractpath just before you call getfile?


answered Aug 30 '17 at 10:57

rgibson's gravatar image


I started that last post and walked away and you posted.... glad you figured it out.


answered Aug 30 '17 at 10:59

rgibson's gravatar image


It's always the little things that trip me up. Thanks for your help.

(Aug 30 '17 at 11:01) eam
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Aug 18 '17 at 16:03

Seen: 946 times

Last updated: Aug 30 '17 at 11:01

powered by OSQA