程序1我用OpenDialog1来添加文件路径
OpenDialog1的程序如下
  OpenDialog1.Execute;
  listbox1.Items.Add(OpenDialog1.FileName);
程序2我的写入文件名的格式是html
procedure  Insert_html(value,htmlfile:string);     //把value写入到htmlfile里面
var  txtfile:TextFile;
begin
  try
    assignfile(txtfile,htmlfile);
    rewrite(txtfile);
    writeln(txtfile,value);
    closefile(txtfile);
   except
      showmessage('写入html文件失败!');
   end;
end;当我不用OpenDialog1控件的时候用程序2就没有问题,我一用OpenDialog1的程序程序1就程序2出错了是不是要把OpenDialog1关闭了还是怎么样??

解决方案 »

  1.   

    你是不是把htmlfile文件名弄错了?
    写入之前,你应该判断procedure  Insert_html(value,htmlfile:string);    //把value写入到htmlfile里面 
    var
      txtfile:TextFile; 
    begin 
      if FileExists(htmlfile) then
      begin
        try 
          assignfile(txtfile,htmlfile); 
          rewrite(txtfile); 
          writeln(txtfile,value); 
          closefile(txtfile); 
        except 
            showmessage('写入html文件失败!'); 
        end; 
      end;
    end; 
      

  2.   

    看看传入的htmlfile路径是什么,看看是否有误
      

  3.   

    不知道是不是我沒看清楚,這是SAVEDIALOG吧??