如何把字符内容存到一个config.txt文件里!谢谢!

解决方案 »

  1.   

    用TFileStream读些文件内容,不管是不是.txt都有效
      

  2.   

    如何写呢?TFileStream是控件还是function呢?
      

  3.   

    var F: TextFile;begin
      AssignFile(F, 'NEWFILE.$$$');
      Rewrite(F);
      Writeln(F, 'Just created file with this text in it...');
      CloseFile(F);
    end;
      

  4.   

    delphi有一个文件类TIniFile就是专门管理配置文档的。可以随便的操作段和节的内容;procedure SaveConfig(Section, Ident: string; Val: Boolean);
    begin
      with TIniFile.Create(GetAppPath + 'Config.ini') do
      begin
        try
          WriteBool(Section, Ident, Val);
        finally
          Free;
        end;
      end;
    end;
      

  5.   

    procedure SetConnectionString(ServerName, UserName, Password: string);
    var
      SYSINI: TINIFile;
      tmpstr: String;
    begin
      SYSINI := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Config.INI');
      try
        with SYSINI do
        begin
          WriteString('Database', 'ServerName', ServerName);
          WriteString('Database', 'UserName', UserName);
          tmpstr := Encrypt(Password, '');
          WriteString('Database', 'Password', tmpstr);
        end;
      finally
        SYSINI.Free;
      end;
    end;
      

  6.   

    哦,存成文体文件呀,easy!
    var
      TxtList:TStringList;
    begin
      TxtList:=TStringList.Create;
      try
        TxtList.Add('这个就是你要存的串!');
        TxtList.SaveToFile('D:\1.txt');
      finally
        TxtList.Free;
      end;
    end;
      

  7.   

    如果是初始化程序,做成INI文件更好
      

  8.   

    想法和blazingfire(烈焰一样)var
      Memo1:TMemo;begin
      Memo1:=TMemo.Create(application.handle);
      try
        Memo1,text:='这个就是你要存的串!';
        Memo1.lines.savetofile(YourFileName);
      finally
        Memo1.free;
      end;
    end;