查找指定文件
查找文件
function FileSearch(const Name, //要查找文件的文件名 DirList: string //指定在哪个目录查找 ): string; //如果函数成功,返回一个包含路径文件名的字符串,否则返回空串
procedure TForm1.N9Click(Sender: TObject); //查找指定文件 FileSearch var FileName,Dir,s: string; begin FileName := 'notepad.exe'; // 要找的文件 Dir := 'c:\windows'; //指定在哪个目录查找 s := FileSearch(FileName,Dir); if s<>'' then //如果上面的函数返回值不为空,则..否则.. ShowMessage(s) //c:\windows\notepad.exe else ShowMessage('没找到'); end;