<!--CodeS-->
function IsFolder(FileName : String) : Boolean;
begin
Result := False;
if IsDirectoryExists(FileName) then Result := True;
end;
<!--CodeE-->
위처럼 하시면 됩니다. 쉽죠? ^^
만약 파일의 존재도 확인하고 싶다면 IsFileExists 함수를 이용하시면 됩니다.
<!--CodeS-->
procedure TForm1.ListFiles(D, Name, SearchName: String);
var
SR: TSearchRec;
begin
if D[Length(D)] <> '\' then
D := D + '\';
if FindFirst(D+Name, faAnyFile, SR) = 0 then
repeat
if (SR.Attr <> faDirectory) and (SR.Name[1] <> '.') then
if AnsiUpperCase(SR.Name) = AnsiUpperCase(SearchName) then
Label1.Caption := D+SR.Name; {파일을 찾으면 label1.Caption에 디렉토리를 표시}
Until (FindNext(SR)<>0);
FindClose(SR);
if FindFirst(D+'*.*', faDirectory, SR) = 0 then
begin
repeat
if ((Sr.Attr and faDirectory) = faDirectory) and
(SR.Name[1]<>'.')
then
ListFiles(D+SR.Name+'\', Name, SearchName); // 재귀호출
until (FindNext(SR) <> 0);
end;
FindClose(SR);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// c:\ 부터 하위 디렉토리에서 delphi32.exe 파일을 찾는다
ListFiles('c:\','*.*','delphi32.exe');
end;
ShellListView에서 선택된 것의 경로를 가지고 확인하시면 됩니다.
예를들면..
<!--CodeS-->
function IsFolder(FileName : String) : Boolean;
begin
Result := False;
if IsDirectoryExists(FileName) then Result := True;
end;
<!--CodeE-->
위처럼 하시면 됩니다. 쉽죠? ^^
만약 파일의 존재도 확인하고 싶다면 IsFileExists 함수를 이용하시면 됩니다.