本文整理自网络,侵删。
//设置当前文件夹 SetCurrentDir; ChDir; SetCurrentDirectory
var
dir: string;
begin
dir := 'c:\temp';
if SetCurrentDir(dir) then
ShowMessage(GetCurrentDir); //c:\temp
//或者
ChDir(dir); //无返回值
//也可以使用API:
SetCurrentDirectory(PChar(Dir)); //返回 Boolean
end;
=====================
function SetCurrentDir(const Dir: string): Boolean;
begin
{$IFDEF MSWINDOWS}
Result := SetCurrentDirectory(PChar(Dir));
{$ENDIF}
{$IFDEF LINUX}
Result := __chdir(PChar(Dir)) = 0;
{$ENDIF}
end;
相关阅读 >>
Delphi xe filesizebyname 要引用哪些文件
Delphi如何把一个文本列表添加到tlistbox并避免重复项
更多相关阅读请进入《Delphi》频道 >>