var
  sl : TStringList;
begin
  sl := TStringList.Create();
  try
    sl.LoadFromFile('path\file.txt');
    sl.Delete(2);  //删除第二行
    sl.SaveToFile('path\file.txt');
  finally
    sl.Free;
  end;
end;

解决方案 »

  1.   

    '--------------------------------------------------------------------
    Dim i as long 
    Dim Fid1 as Long,Fid2 as long
    Dim Path as String
    Dim str as String
    Fid1=FreeFile
    Fid2=FreeFile
    if right(app.path,1)<> "\" then path=app.path & "\"  else path=app.path
    Open Path & "\file.txt" for input as #fid1
    Open Path & "\file.tmp" for Output as #fid2
    i=0
    do while not eof(fid1)
      i=i+1
      if i<>2 then
         line input #fid1,str
         print #fid2,str
      end if
    loop
    close #fid1
    close #fid2
    kill path & "\file.txt"
    filecopy path & "\file.tmp", path & "file.txt"
    kill path & "\file.tmp"'----------------------------------------------------------------
    以上写的程序较为繁杂,处理的速度比起刚才DELPHI写的那段要差,因为DELPHI支持字符列表
    那么这样处理就简单多了,VB大概也只能做这样类似的处理了,但是你可以优化一下上面的代码
    我写的不是最优的,对不起!