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.
Any help would be greatly appreciated.
Thanks,
Alex
Ignorance of certain subjects is a great part of wisdom
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
Thanks,
Alex
Ignorance of certain subjects is a great part of wisdom