zoukankan      html  css  js  c++  java
  • WriteErrorFile() try Except end 错误处理并且保存.txt文件

     
    {写1个错误的日志文件 并记录错误的地方}
    //调用 WriteErrorFile('Button1');
    //try except 在这里放着 end;
    procedure WriteErrorFile(str:string);
    var
        path:string;{FilePath}
        f:TextFile; {txtFile}
        et:string;  {error time}
        ef:string;  {error fileName}
        h:THandle;  {handle}
        el:string;  {error lists}
    begin
        ef:='error.txt';
        path:=ExtractFilePath(Application.ExeName)+ef;  //加上程序已经运行的时间
        et:=FormatDateTime('[yyyy"-"mm"-"dd" "dddd" "hh"-"mm"-"ss]  ',now);
        el:= et + str+'::error ';

        if not FileExists(path) then
          begin
              h:=FileCreate(path);
              FileClose(h);
              AssignFile(F,path);
              Append(F);
              Writeln(F,el);
              CloseFile(F);
          end
        else
          begin
            AssignFile(F,path);
            Append(F);
            Writeln(F,el);
            CloseFile(F);
          end;
    end;




    附件列表

    • 相关阅读:
      linux查找某个命令属于哪个rpm包
      dashboard安装
      yum下载的rpm包离线安装
      jQuery的选择器
      jQuery介绍
      client、offset、scroll系列
      BOM
      js 中的定时器
      JS中的面相对象
      关于DOM操作的相关案例
    • 原文地址:https://www.cnblogs.com/xe2011/p/2541246.html
    Copyright © 2011-2022 走看看