;1.0.4.0 EnableExplicit Global PBEx_FTP #PBEx_FTP_Version$ = "1.0.4.0" #PBEx_FTP_Protocol_FTP = 1 #PBEx_FTP_Protocol_SFTP = 2 #PBEx_FTP_Protocol_FTPS_Implicit = 3 #PBEx_FTP_Protocol_FTPS_Explicit = 4 CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 PBEx_FTP = OpenLibrary(#PB_Any, "PB.Ex_FTP_x86.dll") CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64 PBEx_FTP = OpenLibrary(#PB_Any, "PB.Ex_FTP_x64.dll") CompilerEndIf If PBEx_FTP Prototype OpenFTPEx(ID, Protocol, ServerName.p-Unicode, Port, User.p-Unicode, Password.p-Unicode, Charset, ErrorOutput) Global OpenFTPEx.OpenFTPEx = GetFunction(PBEx_FTP, "OpenFTPEx") Prototype CloseFTPEx(ID, ErrorOutput) Global CloseFTPEx.CloseFTPEx = GetFunction(PBEx_FTP, "CloseFTPEx") Prototype CheckFTPConnectionEx(ID, ErrorOutput) Global CheckFTPConnectionEx.CheckFTPConnectionEx = GetFunction(PBEx_FTP, "CheckFTPConnectionEx") Prototype IsFTPEx(ID, ErrorOutput) Global IsFTPEx.IsFTPEx = GetFunction(PBEx_FTP, "IsFTPEx") Prototype ExamineFTPDirectoryEx(ID, ErrorOutput) Global ExamineFTPDirectoryEx.ExamineFTPDirectoryEx = GetFunction(PBEx_FTP, "ExamineFTPDirectoryEx") Prototype FinishFTPDirectoryEx(ID, ErrorOutput) Global FinishFTPDirectoryEx.FinishFTPDirectoryEx = GetFunction(PBEx_FTP, "FinishFTPDirectoryEx") Prototype NextFTPDirectoryEntryEx(ID, ErrorOutput) Global NextFTPDirectoryEntryEx.NextFTPDirectoryEntryEx = GetFunction(PBEx_FTP, "NextFTPDirectoryEntryEx") Prototype FTPDirectoryEntryNameEx(ID, Output, ErrorOutput) Global FTPDirectoryEntryNameEx.FTPDirectoryEntryNameEx = GetFunction(PBEx_FTP, "FTPDirectoryEntryNameEx") Prototype FTPDirectoryEntrySizeEx(ID, ErrorOutput) Global FTPDirectoryEntrySizeEx.FTPDirectoryEntrySizeEx = GetFunction(PBEx_FTP, "FTPDirectoryEntrySizeEx") Prototype FTPDirectoryEntryTypeEx(ID, ErrorOutput) Global FTPDirectoryEntryTypeEx.FTPDirectoryEntryTypeEx = GetFunction(PBEx_FTP, "FTPDirectoryEntryTypeEx") Prototype FTPDirectoryEntryDateEx(ID, ErrorOutput) Global FTPDirectoryEntryDateEx.FTPDirectoryEntryDateEx = GetFunction(PBEx_FTP, "FTPDirectoryEntryDateEx") Prototype FTPDirectoryEntryAttributesEx(ID, ErrorOutput) Global FTPDirectoryEntryAttributesEx.FTPDirectoryEntryAttributesEx = GetFunction(PBEx_FTP, "FTPDirectoryEntryAttributesEx") Prototype GetFTPDirectoryEx(ID, Output, ErrorOutput) Global GetFTPDirectoryEx.GetFTPDirectoryEx = GetFunction(PBEx_FTP, "GetFTPDirectoryEx") Prototype SetFTPDirectoryEx(ID, DirectoryName.p-Unicode, ErrorOutput) Global SetFTPDirectoryEx.SetFTPDirectoryEx = GetFunction(PBEx_FTP, "SetFTPDirectoryEx") Prototype CreateFTPDirectoryEx(ID, DirectoryName.p-Unicode, ErrorOutput) Global CreateFTPDirectoryEx.CreateFTPDirectoryEx = GetFunction(PBEx_FTP, "CreateFTPDirectoryEx") Prototype DeleteFTPDirectoryEx(ID, DirectoryName.p-Unicode, ErrorOutput) Global DeleteFTPDirectoryEx.DeleteFTPDirectoryEx = GetFunction(PBEx_FTP, "DeleteFTPDirectoryEx") Prototype DeleteFTPFileEx(ID, FileName.p-Unicode, ErrorOutput) Global DeleteFTPFileEx.DeleteFTPFileEx = GetFunction(PBEx_FTP, "DeleteFTPFileEx") Prototype RenameFTPFileEx(ID, FileName.p-Unicode, NewFileName.p-Unicode, ErrorOutput) Global RenameFTPFileEx.RenameFTPFileEx = GetFunction(PBEx_FTP, "RenameFTPFileEx") Prototype ReceiveFTPFileEx(ID, RemoteFileName.p-Unicode, FileName.p-Unicode,IsAsynchron, ErrorOutput) Global ReceiveFTPFileEx.ReceiveFTPFileEx = GetFunction(PBEx_FTP, "ReceiveFTPFileEx") Prototype SendFTPFileEx(ID, FileName.p-Unicode, RemoteFileName.p-Unicode, IsAsynchron, ErrorOutput) Global SendFTPFileEx.SendFTPFileEx = GetFunction(PBEx_FTP, "SendFTPFileEx") Prototype FTPProgressEx(ID, PercentValue, TransferRate, EstimatedTime, ErrorOutput) Global FTPProgressEx.FTPProgressEx = GetFunction(PBEx_FTP, "FTPProgressEx") EndIf Define ErrorOutput$ = Space(128) Define FileName$ = Space(#MAX_PATH) Debug "SFTP..." If OpenFTPEx(1, #PBEx_FTP_Protocol_SFTP, "test.rebex.net", 22, "demo", "password", #PB_UTF8, @ErrorOutput$) ;If OpenFTPEx(1, #PBEx_FTP_Protocol_SFTP, "demo.wftpserver.com", 2222, "demo-user", "demo-user", #PB_UTF8, @ErrorOutput$) SetFTPDirectoryEx(1, "pub", @ErrorOutput$) SetFTPDirectoryEx(1, "example", @ErrorOutput$) ;SetFTPDirectoryEx(1, "download", @ErrorOutput$) ;SetFTPDirectoryEx(1, "upload", @ErrorOutput$) If ExamineFTPDirectoryEx(1, @ErrorOutput$) While NextFTPDirectoryEntryEx(1, @ErrorOutput$) FTPDirectoryEntryNameEx(1, @FileName$, @ErrorOutput$) Debug FileName$ Wend EndIf ; Define a ; Define PercentValue = 0 ; Define TransferRate = 0 ; Define EstimatedTime = 0 ; ; ReceiveFTPFileEx(1, "wftpserver-linux-64bit.tar.gz", "D:\wftpserver-linux-64bit.tar.gz", 1, @ErrorOutput$) ; ; For a=1 To 100 ; FTPProgressEx(1, @PercentValue, @TransferRate, @EstimatedTime, @ErrorOutput$) ; Debug PercentValue ; Debug TransferRate ; Debug EstimatedTime ; Debug "--------" ; Delay(100) ; Next ; ; Delay(10000) CloseFTPEx(1, @ErrorOutput$) Else Debug ErrorOutput$ EndIf Debug "" Debug "FTP..." If OpenFTPEx(1, #PBEx_FTP_Protocol_FTP, "rsbasic.de", 21, "webika3rg_qch3ai", "PureBasic!2016", #PB_UTF8, @ErrorOutput$) If ExamineFTPDirectoryEx(1, @ErrorOutput$) While NextFTPDirectoryEntryEx(1, @ErrorOutput$) FTPDirectoryEntryNameEx(1, @FileName$, @ErrorOutput$) Debug FileName$ Wend EndIf CloseFTPEx(1, @ErrorOutput$) Else Debug ErrorOutput$ EndIf Debug "" Debug "FTPS explicit..." If OpenFTPEx(1, #PBEx_FTP_Protocol_FTPS_Explicit, "test.rebex.net", 21, "demo", "password", #PB_UTF8, @ErrorOutput$) If ExamineFTPDirectoryEx(1, @ErrorOutput$) While NextFTPDirectoryEntryEx(1, @ErrorOutput$) FTPDirectoryEntryNameEx(1, @FileName$, @ErrorOutput$) Debug FileName$ Wend EndIf CloseFTPEx(1, @ErrorOutput$) Else Debug ErrorOutput$ EndIf Debug "" Debug "FTPS implicit..." If OpenFTPEx(1, #PBEx_FTP_Protocol_FTPS_Implicit, "test.rebex.net", 990, "demo", "password", #PB_UTF8, @ErrorOutput$) If ExamineFTPDirectoryEx(1, @ErrorOutput$) While NextFTPDirectoryEntryEx(1, @ErrorOutput$) FTPDirectoryEntryNameEx(1, @FileName$, @ErrorOutput$) Debug FileName$ Wend EndIf CloseFTPEx(1, @ErrorOutput$) Else Debug ErrorOutput$ EndIf CloseLibrary(PBEx_FTP) ; IDE Options = PureBasic 5.60 (Windows - x64) ; CursorPosition = 74 ; FirstLine = 57 ; EnableXP ; EnableUser ; Executable = PB.Ex_MSSQL_x86.exe ; CompileSourceDirectory ; EnableCompileCount = 770 ; EnableBuildCount = 6 ; EnableUnicode