我用cxgrid 读取了 网站上下载的一个数据库文件。 然后另存为了txt的纯文本文件。 因为里面的内容包换了  网页的代码。所以,想在这个txt文件前,加些 内容,最后再加些内容,然后把这个txt文件,改名字,变成一个html扩展名的文件。我这样写的下面的函数。但是可能长度不够的原因。中间少了很多内容。procedure TFrmExportDoc.DealDoc(strFromFile,strSaveFile, strBefore, strAfter: string);
var
  thefile,thefileFrom:textfile;
  s:string;
  AHnd: Integer;
begin   try    if Not FileExists(strSaveFile) then
    begin
      AHnd := FileCreate(strSaveFile);
      FileClose(AHnd);
    end;    assignfile(thefile, strSaveFile);
    Reset(thefile);
    assignfile(thefileFrom , strFromFile );
    Reset(thefileFrom);    Append(thefile);
    Writeln(thefile, strBefore);    Readln(thefileFrom,s);
    Append(thefile);
    Writeln(thefile, s);    Append(thefile);
    Writeln(thefile, strAfter);  finally
    CloseFile(thefile);
    CloseFile(thefileFrom);
  end;请问。如果 在文件前后加 些内容。
另外一个问题,如果修改文件扩展名为 html.
并且把这个html另存为一个word文档。谢谢帮助。

解决方案 »

  1.   

    问题一:
    可以先把内容读出来,然后再加入内容后重写文本文件(本来可以用定位函数来定位的,但是你的内容不确定,所以没办法)
    问题二:重接重命名  AssignFile(TheFile,   '路径+文件名(原文件名)');   
      ReName(TheFile,   '路径+文件名(新文件名)'); 
    问题三:创建word的ole然后把html读入里面,再另存为  
      

  2.   

    谢谢 brightyang(伊莎贝尔) txt里面的内容,都是纯文本文件。
    以前用 blokwrite。但是这个文件前面,想加些 无法加了。 或者用filestream怎么写?谢谢指教!
      

  3.   

    filestream也只能是写流,可以在流后面加,但是不能取长度的