I have a form containing component TOpenDialog( OpenDialog1) and button.
OpenDialog1has the ofAllowMultiSelect(of Options) property equal to true.
After clicking the button, the method is executed AddFilesToListView:
procedure TForm4.AddFilesToListView();
var
ListItem : TListItem;
I: Integer;
F : File;
LengthOfAudio : TDateTime;
previousCursor : TCursor;
begin
previousCursor := Self.Cursor;
Self.Cursor := crHourGlass;
if OpenDialog1.Execute then
begin
for I := 0 to OpenDialog1.Files.Count - 1 do begin
if FileExists(OpenDialog1.FileName) then begin
ListItem:=ListView1.Items.Add;
ListItem.Caption := 'Test';
ListItem.SubItems.Add(ExtractFileName(OpenDialog1.Files[I]));
ListItem.SubItems.Add(ExtractFilePath(OpenDialog1.Files[I]));
end else
raise Exception.Create('File does not exist.');
end;
end;
Self.Cursor := previousCursor;
OpenDialog1.Files.Free;
end;
When launching the application, selecting the first file, I have no problem, but if you want to select the second, I get an error: "Project project3 raised the EInvalidPointer exception class with the message" Invalid Operation Pointer ".
What is the reason for this, how can I fix it?
source
share