local sURL = "http://rgho.st/download/7wjccycyK/52466c789b1f134dfbbedb84f5bcbfe1750f830a/File.bin"; local sLocalFileName = Shell.GetFolder(SHF_DESKTOP).."\\File.bin"; if (File.DoesExist(sLocalFileName) ~= true) then Dialog.Message("Внимание", "Файл не найден.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); Application.Exit(0); else File.Delete(sLocalFileName, false, false, false, nil); Progress.SetVisible("Progress1", true); Label.SetText("Label1", ""); HTTP.Download(sURL, sLocalFileName, MODE_BINARY, nil, nil, nil, nil, ( function (nBytesRead, nFileSize, nTransferRate, nSecondsLeft, sSecondsLeftFormat, sMessage) if (nFileSize == 0) then nFileSize = 1; end Progress.SetCurrentPos("Progress1", nBytesRead/nFileSize*100); Label.SetText("Label1", string.format("%d/%d, %d KB/s", nBytesRead, nFileSize, math.floor(nTransferRate))); end )); local tInfo = HTTP.GetHTTPErrorInfo(); if (tInfo.Number == 0) then Progress.SetVisible("Progress1", false); Label.SetText("Label1", ""); Dialog.Message("Внимание", "Файл загружен.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); else Dialog.Message("Внимание", "Не удалось загрузить файл: "..tInfo.Message, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end end |