Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #RequireAdmin
- #include <FTPEx.au3>
- #include <GuiListBox.au3>
- Global Const $sTitle = "Server"
- Global Const $iWidth = 500
- Global Const $iHeight = 300
- Global $sFTP_Server = "##"
- Global $sFTP_User = "##"
- Global $sFTP_Pass = "##"
- Global $sFTP_Remote = "/daten/"
- Global $hOpen = _FTP_Open($sTitle & "-Verbindung")
- Global $hConn = _FTP_Connect($hOpen, $sFTP_Server, $sFTP_User, $sFTP_Pass)
- If @error Then Exit
- _FTP_DirSetCurrent($hConn, $sFTP_Remote)
- Global $hGui = GUICreate($sTitle, $iWidth, $iHeight)
- Global $hList = GUICtrlCreateList("", 8, 8, $iWidth - 120, $iHeight - 16)
- Global $hDownload = GUICtrlCreateButton("Downloaden", 8 + $iWidth - 120 + 4, 8, $iWidth - 400, 25)
- Global $hUpload = GUICtrlCreateButton("Uploaden", 8 + $iWidth - 120 + 4, 33, $iWidth - 400, 25)
- Global $hDelete = GUICtrlCreateButton("Löschen", 8 + $iWidth - 120 + 4, 58, $iWidth - 400, 25)
- Global $hRename = GUICtrlCreateButton("Umbenennen", 8 + $iWidth - 120 + 4, 83, $iWidth - 400, 25)
- _GetListFromServer($hConn)
- GUISetState()
- While True
- $hMsg = GUIGetMsg()
- Switch $hMsg
- Case -3
- _FTP_Close($hOpen)
- Exit
- Case $hDownload
- $sRead = GUICtrlRead($hList)
- If $sRead = "" Then ContinueLoop
- $vExtension = StringSplit($sRead, ".")
- $vExtension = $vExtension[$vExtension[0]]
- $sNewPathToSave = FileSaveDialog("Speichern unter", "", $vExtension & "-Datei (*." & $vExtension & ")", 2, $sRead, $hGui)
- if @error or $sNewPathToSave = "" Then ContinueLoop
- ProgressOn("Server-Download", $sRead & " downloaden", "0%")
- _FTP_ProgressDownload($hConn, $sNewPathToSave, $sFTP_Remote & $sRead, "_Progress")
- ProgressOff()
- _GetListFromServer($hConn)
- Case $hUpload
- $sLocalFile = FileOpenDialog("Datei auswählen", "", "Alle Dateien (*.*)", 1 + 2, "", $hGui)
- If @error or $sLocalFile = "" Then ContinueLoop
- $sNewName = StringSplit($sLocalFile, "\")
- $sNewName = $sNewName[$sNewName[0]]
- ProgressOn("Server-Upload", $sNewName & " hochladen", "0%")
- _FTP_ProgressUpload($hConn, $sLocalFile, $sFTP_Remote & $sNewName, "_Progress")
- ProgressOff()
- _GetListFromServer($hConn)
- EndSwitch
- WEnd
- Func _GetListFromServer($fhConnection)
- _GUICtrlListBox_BeginUpdate($hList)
- _GUICtrlListBox_ResetContent($hList)
- _GUICtrlListBox_EndUpdate($hList)
- Local $aReturn = _Ftp_ListToArray2D($fhConnection)
- For $iX = 1 To $aReturn[0][0]
- If ($aReturn[$iX][0] <> "." And $aReturn[$iX][0] <> "..") Then _GUICtrlListBox_AddString($hList, $aReturn[$iX][0])
- Next
- Return 1
- EndFunc ;==>_GetListFromServer
- Func _Progress($iPercent = 0)
- ProgressSet($iPercent, $iPercent & "%")
- Return 1
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement