In the sample program, I only change the line below.
Code:
tblURL[1] = "ftp://[<user>[:<password>]@]<host>[:<port>]/<url-path>"
Thanks.
tblURL[1] = "ftp://[<user>[:<password>]@]<host>[:<port>]/<url-path>"
. I thought that it works only on http but on my test, I put the complete FTP URL in the URL field, shown below, and it works:tblURL[1] = "ftp://[<user>[:<password>]@]<host>[:<port>]/<url-path>"
FTPWI.Download("ftp://ftp.yourdomain.com/file.exe", _TempFolder .. "\\file.exe", "FTP_USERNAME", "FTP_PASSWORD", MODE_BINARY, 20, 21, true, nil);
tblDestFiles[1] = _SourceFolder.."\\AutoPlay\\Docs\\01%20-%20Boys%20Don%27t%20Cry.mp3" tblDestFiles[2] = _SourceFolder.."\\AutoPlay\\Docs\\01%20-%20Hermetica%20-%20Vencedores%20Vencidos.mp3" tblDestFiles[3] = _SourceFolder.."\\AutoPlay\\Docs\\01%20El%20deporte%20y%20el%20hombre%20(Primera%20%c3%a9.mp3" tblDestFiles[4] = _SourceFolder.."\\AutoPlay\\Docs\\01.%20Atrocity%20Exhibition.mp3" tblDestFiles[5] = _SourceFolder.."\\AutoPlay\\Docs\\01.Ponernos%20de%20Acuerdo.mp3" tblDestFiles[6] = _SourceFolder.."\\AutoPlay\\Docs\\02%20-%20The%20Trickster.mp3" tblDestFiles[7] = _SourceFolder.."\\AutoPlay\\Docs\\02%20-%20Whatcha%20gonna%20do.mp3" tblDestFiles[8] = _SourceFolder.."\\AutoPlay\\Docs\\02.%20Isolation.mp3" tblDestFiles[9] = _SourceFolder.."\\AutoPlay\\Docs\\02.Luna%20Bonita.mp3" tblDestFiles[10] = _SourceFolder.."\\AutoPlay\\Docs\\03%20Beauty%20Lies%20In%20The%20Eye.mp3" tblDestFiles[11] = _SourceFolder.."\\AutoPlay\\Docs\\03%20The%20Wretched.mp3" tblDestFiles[12] = _SourceFolder.."\\AutoPlay\\Docs\\03-haiducii_-_dragostea_din_tei-WwW.Xtreme*****.NeT.mp3" tblDestFiles[13] = _SourceFolder.."\\AutoPlay\\Docs\\031-mish%20mash%20-%20speechless-www%20servertt%20com.mp3" tblDestFiles[14] = _SourceFolder.."\\AutoPlay\\Docs\\04.%20Life%20On%20Mars.mp3" tblDestFiles[15] = _SourceFolder.."\\AutoPlay\\Docs\\04.%20The%20Man%20Who%20Sold%20The%20World.mp3"
function Dw(m)
if not m then
n = Math.Random(1, 15);
else
n = m
end
if not File.DoesExist(tblDestFiles[n]) then
local session = Download.Start(Application.GetWndHandle(), tblURL[n], tblDestFiles[n], "", "", false, tblProxy, 0, "some text", "another some text");
if (session ~= nil ) then
Table.Insert(tblSessionsToDelete, Table.Count(tblSessionsToDelete)+ 1, session);
local nRow = Grid.InsertRow("Grid1", -1, true);
Grid.SetCellText("Grid1", nRow, 0, session, false);
Grid.SetCellText("Grid1", nRow, 1, "0 KB/S", false);
Grid.SetCellText("Grid1", nRow, 2, "0 Second", false);
Grid.SetCellText("Grid1", nRow, 3, 0, false);
Grid.SetCellText("Grid1", nRow, 4, 0, false);
Grid.SetCellText("Grid1", nRow, 5, "%0", false);
Grid.SetCellText("Grid1", nRow, 6, "Downloading..", false);
end
end
end
function MakeLocalPath(strDestinationDir, strUrl)
local tblMakePath = String.SplitPath(String.Replace(strUrl, "/", "\\\\", false));
local strLocalPath = strDestinationDir..tblMakePath.Filename..tblMakePath.Extension;
return strLocalPath;
end
strLocal = MakeLocalPath(_SourceFolder.."\\AutoPlay\\Docs\\", tblURL[n]); local session = Download.Start(Application.GetWndHandle(), tblURL[n], strLocal, "", "", false, tblProxy, 0, "", "");
function Dw(m)
if not m then
n = n+1
else
n = m
end
local session = Download.Start(Application.GetWndHandle(), tblURL[n], tblDestFiles[n], "", "", false, tblProxy, 0, "some text", "another some text");
if (session ~= nil ) then
Table.Insert(tblSessionsToDelete, Table.Count(tblSessionsToDelete)+ 1, session);
local nRow = Grid.InsertRow("Grid1", -1, true);
Grid.SetCellText("Grid1", nRow, 0, session, false);
Grid.SetCellText("Grid1", nRow, 1, "0 KB/S", false);
Grid.SetCellText("Grid1", nRow, 2, "0 Second", false);
Grid.SetCellText("Grid1", nRow, 3, 0, false);
Grid.SetCellText("Grid1", nRow, 4, 0, false);
Grid.SetCellText("Grid1", nRow, 5, "%0", false);
Grid.SetCellText("Grid1", nRow, 6, "Downloading..", false);
end
end
function Download.OnComplete(tblData)
Download.Delete(tblData.Session);
if (tblData.Data == "DialogEx1") then
Label.SetText("Label1", "Completed..");
else
local nRow = FindRow(tblData.Session);
if(nRow > 0) then
Grid.SetCellText("Grid1", nRow, 6, "Completed", true);
Dw()--It Starts a new download
end
end
end
function Download.OnError(tblData)
Download.Delete(tblData.Session); -- Important !! - do not forget to call this first
if (tblData.Data == "DialogEx1") then
Label.SetText("Label1", "Error Occured..");
else
local nRow = FindRow(tblData.Session);
if(nRow > 0) then
Grid.SetCellText("Grid1", nRow, 1, "0 KB/S", true);
Grid.SetCellText("Grid1", nRow, 2, "0 Seconds", true);
Grid.SetCellText("Grid1", nRow, 3, "0 KB", true);
Grid.SetCellText("Grid1", nRow, 4, "0 KB", true);
Grid.SetCellText("Grid1", nRow, 5, "% 0", true);
Grid.SetCellText("Grid1", nRow, 6, "Error Occured", true);
Dw(n)--Restart the download
end
end
end
tblURL[1] = "http://www.laisladelax.com.ar/mp3/01%20-%20Boys%20Don%27t%20Cry.mp3" tblURL[2] = "http://www.laisladelax.com.ar/mp3/01%20-%20Hermetica%20-%20Vencedores%20Vencidos.mp3" tblURL[3] = "http://www.laisladelax.com.ar/mp3/01%20El%20deporte%20y%20el%20hombre%20(Primera%20%c3%a9.mp3" tblURL[4] = "http://www.laisladelax.com.ar/mp3/01.%20Atrocity%20Exhibition.mp3" tblURL[5] = "http://www.laisladelax.com.ar/mp3/01.Ponernos%20de%20Acuerdo.mp3" tblURL[6] = "http://www.laisladelax.com.ar/mp3/02%20-%20The%20Trickster.mp3" tblURL[7] = "http://www.laisladelax.com.ar/mp3/02%20-%20Whatcha%20gonna%20do.mp3" tblURL[8] = "http://www.laisladelax.com.ar/mp3/02.%20Isolation.mp3" tblURL[9] = "http://www.laisladelax.com.ar/mp3/02.Luna%20Bonita.mp3" tblURL[10] = "http://www.laisladelax.com.ar/mp3/03%20Beauty%20Lies%20In%20The%20Eye.mp3" tblURL[11] = "http://www.laisladelax.com.ar/mp3/03%20The%20Wretched.mp3" tblURL[12] = "http://www.laisladelax.com.ar/mp3/03-haiducii_-_dragostea_din_tei-WwW.Xtreme*****.NeT.mp3" tblURL[13] = "http://www.laisladelax.com.ar/mp3/031-mish%20mash%20-%20speechless-www%20servertt%20com.mp3" tblURL[14] = "http://www.laisladelax.com.ar/mp3/04.%20Life%20On%20Mars.mp3" tblURL[15] = "http://www.laisladelax.com.ar/mp3/04.%20The%20Man%20Who%20Sold%20The%20World.mp3"
tblProxy = {}
tblProxy.Ip = "";
tblProxy.Port = 0;
tblProxy.Username = "";
tblProxy.Password = "";
Dw(n)
Leave a comment: