Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wininet.dll question 1

Status
Not open for further replies.

AlexCuse

Programmer
Apr 13, 2006
5,416
US
Hi All,

I have a function that uses wininet.dll to download files from an FTP site. It is modified from the FAQ's found in this forum posted by 1DMF. It is working well, except it is saving my file as a read-only file. This makes it a pain for me to delete the file when I am done processing. Has anyone run into this problem before?

I have been unable to find much documentation on the different functions, at least in a VBA context. (I think I may be misusing one of the parameters)

What I need is either what I need to do in order to get this to save as a normal file, or a work-around in VBA to convert the file to read/write. Here is my function as it is now.
Code:
Function FTPDownFile(ByVal HostName As String, _
    ByVal UserName As String, _
    ByVal Password As String, _
    ByVal LocalFileName As String, _
    ByVal RemoteFileName As String, _
    ByVal sDir As String, _
    ByVal sMode As String) As Boolean
  
        
' Declare variables
Dim hConnection, hOpen ' Used For Handles

'VBA.Kill LocalFileName
        
' Open Internet Connecion
hOpen = InternetOpen("FTP", 1, "", vbNullString, 0)

' Connect to FTP
hConnection = InternetConnect(hOpen, HostName, 21, UserName, Password, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)

' Change Directory
Call FtpSetCurrentDirectory(hConnection, sDir)

' Set Download Flag to True
FTPDownFile = True


      
    ' Download File
    If FTPGetFile(hConnection, RemoteFileName, LocalFileName, False, 1, 1, 1) = False Then
        MsgBox "Download - Failed At FTPGetFile!"
        ShowError
        FTPDownFile = False
    End If
    

' Close Internet Connection
Call InternetCloseHandle(hOpen)
Call InternetCloseHandle(hConnection)

End Function
Any help would be greatly appreciated.

Thanks,

Alex



Ignorance of certain subjects is a great part of wisdom
 
Something like this ?
SetAttr LocalFileName, vbNormal + vbArchive

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hehe, thanks PH. Just wanted to check if there was a way to do this through the FTP transfer.

You the man, as usual! Have another star for the collection ;-)

Alex

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top