![]() |
|
|
|
|
#1
|
|||
|
|||
|
В общем с толкнулся с такой проблемой, необходимо приконнектиться к фтп серверу и просто подсчитать количество содержащихся в указанной дирректории файлов исключая подпапки и вложенные в них файлы. С конектом разобрался, а вот подсчитать немогу. Вывыливается с ошибкой
class EListError with message 'List index out of bounds (0)' var i,count:integer; begin count :=0; DirectoryListBox.ItemIndex := 0; for i:=1 to DirectoryListBox.Count do begin if IdFTP1.DirectoryListing.Items[DirectoryListBox.ItemIndex].ItemType=ditDirectory then count := count else count:= count + 1; DirectoryListBox.ItemIndex := DirectoryListBox.ItemIndex + 1; end; ShowMessage(IntToStr(Count)); end; |
|
#2
|
|||
|
|||
|
Списки (ака TList) начинаются с 0.
Код:
for i := 0 to List.Count - 1 do |
|
#3
|
|||
|
|||
|
проблема в этой строке
if IdFTP1.DirectoryListing.Items[DirectoryListBox.ItemIndex].ItemType=ditDirectory, непонятно почему |
|
#4
|
|||
|
|||
|
Попробуй так:
Код:
var
i, MyCount: integer;
begin
MyCount:=0;
for i := 0 to DirectoryListBox.Count - 1 do
if IdFTP1.DirectoryListing.Items[i].ItemType <> ditDirectory then
Inc(MyCount);
ShowMessage(IntToStr(MyCount));
end; |
|
#5
|
|||
|
|||
|
Постараюсь немного уточнить вопрос:
После соединения с фтп сервером и забивания каталогов в ListBox, пытаюсь определить файл это или папка if IdFTP1.DirectoryListing.Items[DirectoryListBox.ItemIndex].ItemType =ditDirectory выпадает ошибка - "List index out of bounds" при етом - IdFTP1.DirectoryListing.Items.Count = 0 IdFTP1.DirectoryListing.DirectoryName пустое Последний раз редактировалось Apple, 18.05.2007 в 18:32. |
|
#6
|
||||
|
||||
|
Цитата:
ItemIndex - это выбраный элемент! if IdFTP1.DirectoryListing.Items[i].ItemType =ditDirectory |