要得到所有C:\Documents and Settings\aaa\Local Settings\Temporary Internet Files下的swf文件,把文件名放到LISTBOX里,好像不行啊。我用下面的方法,其它路径的文件是可以的,可这个目录的文件却是不行的,高手帮忙啊
var
Path : string;
SR : TSearchRec;
begin
Path:= 文件夹路径;
Self.ListBox1.Items.Clear;
if FindFirst(Path+'\*.swf',faArchive,SR)=0 then
repeat
ListBox1.Items.Add(path+'\'+SR.Name);
until FindNext(RS) <> 0;
FindClose(RS);
var
Path : string;
SR : TSearchRec;
begin
Path:= 文件夹路径;
Self.ListBox1.Items.Clear;
if FindFirst(Path+'\*.swf',faArchive,SR)=0 then
repeat
ListBox1.Items.Add(path+'\'+SR.Name);
until FindNext(RS) <> 0;
FindClose(RS);
var
f: TSearchRec;
Ret: Integer;
begin
FileEx := UpperCase(FileEx);
Result := TStringList.Create;
Ret := FindFirst(Path + '\*.*', faAnyFile, f);
while Ret = 0 do
begin
if f.Attr = faDirectory then
begin
if (f.Name <> '.') and (f.Name <> '..') then
GetAllFile(Path + '\' + f.Name)
end
else
if (FileEx = '*.*') or (UpperCase(ExtractFileExt(f.Name)) = FileEx) then Result.Append(Path + '\' + f.Name); Ret := FindNext(f)
end;
FindClose(f)
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Assign(GetAllFile('c:\windows', '.swf));
end;
function
GetShortName( sLongName : string )
: string;
var
sShortName : string;
nShortNameLen : integer;
begin
SetLength( sShortName,
MAX_PATH ); nShortNameLen :=
GetShortPathName(
PChar( sLongName ),
PChar( sShortName ),
MAX_PATH - 1 ); if( 0 = nShortNameLen )then
begin
// handle errors...
end; SetLength( sShortName,
nShortNameLen ); Result := sShortName;
end;