【发布时间】:2009-06-30 17:39:51
【问题描述】:
我有一个包含 TOpenDialog 组件 (OpenDialog1) 和按钮的表单。
OpenDialog1 的 ofAllowMultiSelect(Options)属性设置为 true。
点击按钮后,方法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;
在运行应用程序时,选择第一个文件,我没有问题,但是当我想选择第二个文件时,我收到一条错误消息“项目 project3 引发异常类 EInvalidPointer 并带有消息'无效指针操作'。”
这是什么原因,我该如何纠正?
【问题讨论】:
标签: delphi openfiledialog