procedure Tsetsys.FormCreate(Sender: TObject);
begin
   myinifile:=Tinifile.Create(getCurrentDir+'\system.ini');
   edit1.text:=myinifile.ReadString('upload','path','');
   label1.Caption:=myinifile.ReadString('upload','path','');
end;procedure Tsetsys.BitBtn1Click(Sender: TObject);
begin
   // if not directoryexists(edit1.text) then
    if not directoryexists(label1.Caption) then
    showmessage('设定的目录不存在!请重新设置!')
    else
    begin
     myinifile.WriteString('upload','path',edit1.text);
     myinifile.Destroy;
     setsys.Close;
   end;
end;
是不是getCurrentDir用的不对啊?该怎么写??

解决方案 »

  1.   

    忘记说了,我的窗口上用dirvercombox、directorylistbox;
    directorylistbox的listlabel为label1;选择后自动将路径保存到system.ini
      

  2.   

    myinifile:=Tinifile.Create('.\system.ini');
      

  3.   

    implementation
    var
    myinifile:Tinifile;
    改了还不行,可能是我没说明白,我的ini和程序在一个目录理,当我设置好路径保存后,程序就在选择的目录理新建了个ini文件?
      

  4.   

    你的问题出在当你有打开文件或者有路径操作时,GetCurrentDir得到的是你最后操作所在的目录。
    简单的解决办法是声明一个成员变量在主form create时,将路径信息保存下来:
    如:   IniPath := GetCurrentDir;以后再用到ini文件时加上IniPath就ok 了。
      

  5.   

    我也遇到过,路径必须加全路径,使用相对路径的话,会随着程序的执行而改变的
    我用的  ExtractFilePath(Application.Exename)+'system.ini'