NeuroToxic Posted December 31, 2007 Share Posted December 31, 2007 Hi all. Sorry for my bad english, I'm french. I have a problem with the FTPDelDir() of FTP.au3 UDF of Wouter. All other functions works properly. I have a FTP server with one dir and in this dir, several files. This dir is named : "exemple" When I use the FTPDelDir(), this dir is not deleled. The code : $server = 'my_host' $username = 'my_user_name' $pass = 'my_pass' $Open = _FTPOpen('MyFTP Control') $Conn = _FTPConnect($Open, $server, $username, $pass) $Ftpd = _FtpDelDir($Conn, 'exemple') $Ftpc = _FTPClose($Open) I try too, with the dir "exemple" but Without file in it. It still does not work How, this function works ? thank you Link to comment Share on other sites More sharing options...
weaponx Posted December 31, 2007 Share Posted December 31, 2007 Make sure the folder you are trying to delete has chmod set to proper permissions. Link to comment Share on other sites More sharing options...
NeuroToxic Posted December 31, 2007 Author Share Posted December 31, 2007 I'm root Link to comment Share on other sites More sharing options...
weaponx Posted December 31, 2007 Share Posted December 31, 2007 On my ftp server any time I create a new file or folder the default permissions are set to 000 and I have to chmod to 744 or 777 so I can delete the file. Link to comment Share on other sites More sharing options...
Zedna Posted December 31, 2007 Share Posted December 31, 2007 Look here Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
NeuroToxic Posted January 1, 2008 Author Share Posted January 1, 2008 I have change my code with the "DllOpen" but it still does not work $server = 'my_host' $username = 'my_user_name' $pass = 'my_pass' $dllhandle = DllOpen('wininet.dll') $Open = _FTPOpen('MyFTP Control') $Conn = _FTPConnect($Open, $server, $username, $pass) $Ftpd = _FtpDelDir($Conn, 'exemple') $Ftpc = _FTPClose($Open) DllClose($dllhandle) Link to comment Share on other sites More sharing options...
NeuroToxic Posted January 1, 2008 Author Share Posted January 1, 2008 When the directory is empty, the function FTPDelDir() works, otherwise. Then I try to make a FTPDelDirRecurse() but I have a problem in my script, I don't understand why it don't works. Can you look my code ? The code : [autoit]#include "ftp3.au3" $server = 'my_ftp_server' $username = 'my_username' $pass = 'my_password' $ftp_main_dir = '/exemple/' $ftp_file_mask = '*.*' $dllhandle = DllOpen('wininet.dll') $Open = _FTPOpen('MyFTP Control') If @error Then MsgBox(0, "error", "Open") $Conn = _FTPConnect($Open, $server, $username, $pass) If @error Then MsgBox(0, "error", "Connect") FTPDelDirRecurse($ftp_main_dir) _FTPClose($Open) DllClose($dllhandle) Func FTPDelDirRecurse($ftp_dir) Dim $Handle Dim $DllRect Local $FileInfo = _FtpFileFindFirst($Conn, $ftp_dir & $ftp_file_mask, $Handle, $DllRect) If $FileInfo[0] Then Do ;~ If current is directory If $FileInfo[1] == 16 And $FileInfo[10] <> "." And $FileInfo[10] <> ".." Then ; dir attrib = 16 MsgBox(0, "Current dir", $FileInfo[10]) Local $i = $ftp_dir & $FileInfo[10] & "/" FTPDelDirRecurse($i) EndIf ;~ If current is file If $FileInfo[1] == 128 Then ; file attrib = 128 MsgBox(0, "Current file", $FileInfo[10]) _FTPDelFile($Conn, $ftp_dir & $FileInfo[10]) EndIf $FileInfo = _FtpFileFindNext($Handle, $DllRect) Until Not $FileInfo[0] EndIf _FtpFileFindClose($Handle, $DllRect) EndFunc ;==> FTPDelDirRecurse Link to comment Share on other sites More sharing options...
Zedna Posted January 4, 2008 Share Posted January 4, 2008 and the ftp3.au3 UDF : ;=============================================================================== ; ; Function Name: _FTPGetFileSize() ; Description: Gets filesize of a file on the FTP server. ; Parameter(s): $l_FTPSession - The Long from _FTPConnect() ; $s_FileName - The file name. ; Requirement(s): DllCall, wininet.dll ; Return Value(s): On Success - 1 ; On Failure - 0 ; Author(s): J.o.a.c.h.i.m. d.e. K.o.n.i.n.g. ; ;=============================================================================== Func _FTPGetFileSize($l_FTPSession, $s_FileName) Local $ai_FTPGetSizeHandle = DllCall('wininet.dll', 'int', 'FtpOpenFile', 'long', $l_FTPSession, 'str', $s_FileName, 'long', 0x80000000, 'long', 0x04000002, 'long', 0) Local $ai_FTPGetFileSize = DllCall('wininet.dll', 'int', 'FtpGetFileSize', 'long', $ai_FTPGetSizeHandle[0]) If @error OR $ai_FTPGetFileSize[0] = 0 Then SetError(-1) Return 0 EndIf DllCall('wininet.dll', 'int', 'InternetCloseHandle', 'str', $l_FTPSession) Return $ai_FTPGetFileSize[0] EndFunc ;==> _FTPGetFileSize() ;=============================================================================== Look here Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
NeuroToxic Posted January 5, 2008 Author Share Posted January 5, 2008 It was not working because files were present in the folders, the _FTPDelDir() is not recursive. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now