PDA

View Full Version : ftp problem



TristanD
01-11-2007, 04:20 PM
hi, i;ve got a little problem.. can someone tell me why the name of the file/folder does not get set as the data in the LB?


ftp_dir_index = FTP.List();

-- add each item to the listbox in this format:
-- <name> (<size>)
for i = 1, ftp_dir_index.Count do
local name = ftp_dir_index[i].Name;
local size = ftp_dir_index[i].Size;
local date = ftp_dir_index[i].Date;
ftp_file_info = FTP.GetFileInfo(name);

if ftp_dir_index[i].Type == FTP.FOLDER then
-- add a [ ] prefix to make the folders stand out in the listbox
ListBox.AddItem("ftp_dir_index", "[ FOLDER ] "..name.." ("..size.." bytes) ", name);

else
ListBox.AddItem("ftp_dir_index", "[ FILE ] "..name.." ("..size.." bytes) ", name);
end
ListBox.SetUpdate("ftp_dir_index", true);
end

Tek
01-11-2007, 04:58 PM
Hmm well it seems to be working for me on the FTP site I tested with.

Try adding this to your 'On Select' actions for the listbox. It will tell you the data field when you click on it. Again, it appears to work for me. Not sure if it's a problem with your connection to the FTP server since I'm assuming you can see the listbox being populated, right?



tSelected = ListBox.GetSelected("ftp_dir_index");
for index in tSelected do
Dialog.Message("Listbox Data Field", ListBox.GetItemData("ftp_dir_index", tSelected[index]), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

TristanD
01-11-2007, 11:58 PM
Not sure if it's a problem with your connection to the FTP server since I'm assuming you can see the listbox being populated, right?
[/code]

yeah it does get populated.. i've made the listbox change the text of a label to the itemdata on double click and it went blank.. your little solution worked ;)

thanks, Tristan