My Declarations
and my rename codeCode:Public Declare Function apiFtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" (ByVal hConnect As Long, ByVal lpszExisting As String, ByVal lpszNew As String) As Boolean Public Declare Function apiFtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal hConnect As Long, ByVal lpszFileName As String) As Boolean Public Declare Function apiFtpCreateDirectory Lib "wininet.dll" Alias "FtpCreateDirectoryA" (ByVal hConnect As Long, ByVal lpszDirectory As String) As Boolean Public Declare Function apiFtpRemoveDirectory Lib "wininet.dll" Alias "FtpRemoveDirectoryA" (ByVal hConnect As Long, ByVal lpszDirectory As String) As Boolean
Now it works fine but still raises an error (lastdll) of 2 - which I think is that it cannot find the file.Code:Public Function RenameFile(ByVal strOldName As String, ByVal strNewName As String, ByVal blnFtpFile As Boolean) As Boolean '---- FTP - '---- will work on the current directory (make sure you are there before calling) '---- Local - '---- Use fill file path names '---- Note: To rename a directory, use this function Dim lngRes As Long On Error Resume Next RenameFile = True If blnFtpFile Then If IntCon.zIntConHandle <> 0 Then lngRes = apiFtpRenameFile(IntCon.zIntConHandle, ByVal strOldName, ByVal strNewName) End If Else '---- local drive rename ' lngRes = apiMoveFile(strOldName, strNewName) 'only api to rename a local file End If '---- repeated error msg/clean up If Err.Number <> 0 Then RenameFile = False MsgBox "Error : " & Err.Number & vbCrLf & Err.Description, vbOKOnly + vbExclamation, "Error" Err.Clear End If If Err.LastDllError <> 0 Then RenameFile = False MsgBox "Last DLL Error : " & Err.LastDllError, vbOKOnly + vbExclamation, "Error Last Error" Err.Clear End If End Function
I am tempted to ignore that error as it is working, but I wanted to make sure.
I looked on google, but MSDN says it`s a function, and ActiveVB says its a sub. Confused? I am!
The function sounds better (at least you'd know if it worked of not).
Comments?




Reply With Quote